This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |