题解 P2058 【海港】

· · 题解

用一个队列来存储

比赛的时候看到这个所有ki的和<=300000偏偏没想到按人头存储。。。

#include<iostream>
using namespace std;
int s,i,n,t,k,r,w[100001],x[300002],y[300002];

main(){
    cin>>n;
    while(n--){
        cin>>t>>k;
        while(k--){
            y[++r]=t;cin>>x[r];
            if(!w[x[r]])s++;
            w[x[r]]++;
        }
        while(t-y[i]>=86400)
            if(!--w[x[i++]])s--;
        cout<<s<<endl;
    }
}