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 <iostream>
using namespace std;
long long int k[100005],n,c,r,son[5005][5005],tag[100005];
int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) {
n=N;
c=C;
r=R;
for(int i=0;i<c;i++)
{
long long int cnt=-1;
for(int j=0;j<n;j++)
{
if(tag[j]==0)cnt++;
if(cnt>=S[i] && cnt<=E[i] && tag[j]==0)
{
son[i][0]++;
son[i][son[i][0]]=j;
if(cnt!=S[i])tag[j]=1;
//cout<<son[i][son[i][0]]<<" ";
}
}
//cout<<endl;
}
long long int ans=0,p=0;
for(int i=0;i<n;i++)
{
k[i]=r;
long long int cnt=0;
for(int j=0;j<i;j++)k[j]=K[j];
for(int j=i+1;j<n;j++)k[j]=K[j-1];
//for(int j=0;j<n;j++)cout<<k[j]<<" ";
//cout<<endl;
long long int ma=0;
for(int l=1;l<=c;l++)
{
ma=0;
for(int j=1;j<=son[l][0];j++)
{
ma=max(k[son[l][j]],ma);
}
if(ma==r)cnt++;
k[son[l][1]]=ma;
}
//cout<<i<<" "<<cnt<<endl;
if(cnt>ans)
{
ans=cnt;
p=i;
}
}
return p;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |