P2058
代码:
#include<iostream>
#include<queue>
#include<string.h>
#include<cstdio>
#define code ac
#define cspj win
using namespace std;
struct node{
int tim;
int man;
int gj[10005];
};
using namespace std;
queue <node> p;
// int a[100005];
int main(){
int n;
cin>>n;
while(n--){
int a[100005]={0};
node ne;
// cin>>ne.tim>>ne.man;
scanf("%d%d",&ne.tim,&ne.man);
for(int i=0;i<ne.man;i++){
// cin>>ne.gj[i];
scanf("%d",&ne.gj[i]);
}
p.push(ne);
int si=p.size();
for(int i=0;i<si;i++){
if(p.front().tim>ne.tim-86400) p.push(p.front());
p.pop();
}
// cout<<p.size()<<endl;
si=p.size();
int ma=0;
// memset(a,0,sizeof(a));
for(int i=0;i<si;i++){
node s=p.front();
p.push(s),p.pop();
int j=0;
while(s.man--){
if(s.gj[j]>ma) ma=s.gj[j];
a[s.gj[j++]]++;
}
}
int ans=0;
for(int j=1;j<=ma;j++){
if(a[j]) ans++;
// cout<<j<<" ";
}
printf("%d\n",ans);
}
}
这段代码只得了70分,剩下30%都超时了……
大佬们给点更改的建议吧,拜托了!