1284 海港 普及组 NOIP2016 队列基础 简单枚举 简单模拟 优先队列(priority_queue)

NB,标签大王

也可以知道,就是队列模拟了

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5+10;
struct node{
    int t,x;
}; 
queue<node>q;
int a[N];
int n,k,x,t,ans;
node r;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d %d",&r.t,&k);
        t = r.t;
        for(int j=1;j<=k;j++)
        {
            scanf("%d",&r.x);
            if(!a[r.x])ans++;
            a[r.x]++;
            q.push(r);
        }
        r = q.front();
        while(!q.empty() && t-r.t>=86400)
        {
            q.pop();
            a[r.x]--;
            if(!a[r.x])ans--;
            r = q.front();
        }
        cout<<ans<<endl;
    }
     return 0;
}

 

posted @ 2024-06-28 15:14  CRt0729  阅读(5)  评论(0编辑  收藏  举报