错的地方比正确答案少1 ,40求助
查看原帖
错的地方比正确答案少1 ,40求助
65987
SuperGoodGame楼主2022/4/28 17:55

然而并不知道哪里错了,感觉和题解思路完全一致

#include<iostream>
#include <cstdio>
#include <cstring>
#define N 1000005
#include <vector>
#define re register
using namespace std;
int h[N] , n , head=1,ans=0;
vector<int> a[N];
int main() {
	scanf("%d",&n);
	for(re int i=1;i<=n;i++){
		int t,tn;
		scanf("%d%d",&t,&tn);
		a[i].push_back(t);
		for(re int j=1;j<=tn;j++){
			int now;
			scanf("%d",&now);
			h[now]++; if(h[now]==1) ans++;
			a[i].push_back(now);
		}
		while(a[head][0]<=t-86400 && head<i){
			for(re int j=1;j<=a[head].size();j++){
				h[a[head][j]]--; if(h[a[head][j]]==0) ans--;
			}
			head++;
		}
		cout<<ans<<endl;
	}
}
2022/4/28 17:55
加载中...