求助,洛谷WA,XJOI TLE
查看原帖
求助,洛谷WA,XJOI TLE
242524
JRzyh楼主2020/7/13 21:18

洛谷:https://www.luogu.com.cn/record/35118931

XJOI:https://dev.xjoi.net/contest/detail/446514

#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
struct node
{
	int s,t;
};
int n,t,m,ans,a[1000008];
queue<node>sh;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>t>>m;
		while(!sh.empty())
		{
			node h=sh.front();
			if(h.t+86400<t)
			{
				a[h.s]--;
				if(a[h.s]==0)ans--;
				sh.pop();
				continue;
			}
			else break;
		}
		for(int i=1;i<=m;i++)
		{
			node h;
			int x;
			cin>>x;
			h.s=x;
			h.t=t;
			sh.push(h);
			if(a[h.s]==0)ans++;
			a[h.s]++;
		}
		cout<<ans<<endl;
	}
	return 0;
}
2020/7/13 21:18
加载中...