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<vector>
#include<iostream>
using namespace std;
typedef long long ll;
int GetBestPosition(int n,int c,int r,int *K,int *L,int *R){
for(int i=0;i<c;i++)
R[i]++;
vector<int>present(n,1);
for(int j=0;j<c;j++){
int sum=0;
int l=n,r=n;
for(int i=0;i<n;i++){
if(sum==L[j])
l=i;
if(sum==R[j])
r=i;
sum+=present[i];
}
L[j]=l;
R[j]=r;
for(int i=l;i<r-1;i++)
present[i]=0;
}
vector<int>arr_glob(n-1);
for(int i=0;i<n-1;i++)
arr_glob[i]=K[i];
int max_res=-1;
int i_res=0;
for(int ins=0;ins<n;ins++){
vector<int>arr=arr_glob;
arr.insert(arr.begin()+ins,r);
int res=0;
for(int j=0;j<c;j++){
int m=0;
for(int i=L[j];i<R[j];i++)
m=max(m,arr[i]);
res+=m==r;
}
//cout<<ins<<" "<<res<<"\n";
if(res>max_res){
max_res=res;
i_res=ins;
}
}
return i_res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |