Submission #18805

#TimeUsernameProblemLanguageResultExecution timeMemory
18805ggohJousting tournament (IOI12_tournament)C++98
49 / 100
1000 ms4360 KiB
#include<cstdio> #include<set> int maxx=-1,l,j,a,sz,ss[100003],ee[100003],sum[100003],b,c,i,x[100002],st[100002],en[100002],d[100004]; bool check[100002]; int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) { a=N; b=C; for(i=0;i<a;i++)ss[sz]=i,ee[sz]=i,sz++; for(i=0;i<b;i++) { st[i]=ss[S[i]]; en[i]=ee[E[i]]; ss[S[i]]=st[i];ee[S[i]]=en[i]; for(j=E[i]+1;j<sz;j++) { ss[j-(E[i]-S[i])]=ss[j]; ee[j-(E[i]-S[i])]=ee[j]; } sz=sz-(E[i]-S[i]); } for(i=0;i<a-1;i++){if(K[i]>R)x[i]=1;else x[i]=0;} sum[0]=x[0]; for(i=1;i<a-1;i++)sum[i]=sum[i-1]+x[i]; for(i=0;i<b;i++) { if(sum[en[i]-1]-(st[i]?sum[st[i]-1]:0)==0)check[i]=1; else check[i]=0; } for(i=0;i<b;i++)if(check[i]) { d[st[i]]++; d[en[i]+1]--; } c=0; for(i=0;i<a;i++) { c+=d[i]; if(c>maxx)maxx=c,l=i; } return l; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...