70分求助,6个tle
查看原帖
70分求助,6个tle
958427
laotou333楼主2024/3/23 08:58
#include <bits/stdc++.h>
using namespace std;
struct node{
	int time;
	int number;
};
int main(){
	queue<node> q;
	queue<int> ansq;
	node o;
	int ans=0,r=0,q_=0,ansq_=0,in=0,x=0,n=0,t=0;
	cin>>n; 
	for(int i=0;i<n;i++){
		cin>>t;
		cin>>x;
		for(int i1=0;i1<x;i1++){
			q_++;
			cin>>in;
			q.push({t,in});
		}
		for(int i1=0;i1<q_;i1++){
			o=q.front();
			q.push(o);
			q.pop(); 
			if(t-o.time<86400){
				if(!ansq.empty()){
					int flag=0;
					for(int i2=0;i2<ansq_;i2++){
						r=ansq.front();
						ansq.push(r);
						ansq.pop();
						if(r==o.number){
							flag=1;
							break;
						}
					}
					if(flag==1){
						continue;
					}else{
						ansq.push(o.number);
						ansq_++;
						ans++; 
					}
				}else{
					ans++;
					ansq_++;
					ansq.push(o.number);
				}
			}
		}
		cout<<ans<<endl;
		ans=0;
		ansq_=0;
		while(!ansq.empty()){
			ansq.pop();
		}
	}
	return 0; 
}
2024/3/23 08:58
加载中...