模拟题,刚开始准备对每个船用队列进行储存,但是等船离开时每次都会遍历一遍这条船,时间复杂度为o(mn)。所以应该存每个人
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+10;
int a[N];//存人
int q[N];//存时间
int v[N];
int tt = -1 , hh;
long long ans;
int main()
{
int n;
cin>>n;
int p;
int t;
for(int i = 0 ; i < n ; i++)
{
cin>>t>>p;
int x;
for(int j = 0 ; j < p ; j++)
{
q[++tt] = t;
cin>>x;
a[tt] = x;
if(!v[x]) ans++;
v[x]++;
}
while(t-q[hh]>=86400)
{
if(!--v[a[hh++]]) ans--;
}
cout<<ans<<endl;
}
return 0;
}