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>
#include <vector>
#include <assert.h>
#include <set>
using namespace std;
typedef pair<int,int> pii;
int RT[4000005];
int inizio[400005],fine[400005];
pii ans;
int P;
set<int> Q;
int converti(int k){
int res=0;
for(int i=0;i<k+1;)
if(RT[res++])
i++;
return res-1;
}
void elimina(int x, int y){
for(int i=x;i<=y;i++)
RT[i]=0;
}
int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) {
for(int i=0;i<400005;i++)
RT[i]=1;
for(int i=0;i<C;i++){
S[i]=converti(S[i]);
E[i]=converti(E[i]+1);
elimina(S[i]+1,E[i]-1);
}
for(int i=0;i<N-1;i++)
if(K[i]>R)
Q.insert(i);
for(int i=0;i<C;i++)
if(*Q.lower_bound(S[i])<E[i]-1)
S[i]=E[i]=-1;
/*
for(int i=0;i<C;i++)
for(int j=S[i];j<E[i]-1;j++)
if(K[j]>R){
S[i]=E[i]=-1;
break;
}*/
for(int i=0;i<C;i++)
if(S[i]!=-1){
inizio[S[i]]++;
fine[E[i]]++;
}
for(int pos=0;pos<N;pos++){
P+=inizio[pos];
P-=fine[pos];
ans=max(ans,{P,-pos});
}
return -ans.second;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |