AcWing 467. 海港
原题链接
简单
作者:
一只迷路的小A
,
2021-02-01 19:24:10
,
所有人可见
,
阅读 385
#include<bits/stdc++.h>
using namespace std;
int n,ti,ki,x;
int ans;
int natin[300010];
struct node
{
int t;
int g;
};
queue<node>boat;
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d%d",&ti,&ki);
while(!boat.empty())
{
node now=boat.front();
if(now.t<=ti-86400)
{
natin[now.g ]--;
if(natin[now.g ]==0) ans--;
boat.pop();
continue;
}
break;
}
for(int j=1;j<=ki ;j++)
{
scanf("%d",&x);
node now;
now.t =ti;now.g =x;
boat.push(now);
natin[x]++;
if(natin[x]==1) ans++;
}
printf("%d\n",ans);
}
return 0;
}