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 <bits/stdc++.h>
using namespace std;
int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) {
//printf("here");
vector<int> X;
X.push_back(1);
for(int i = 0; i < N-1; i ++){
if(K[i] < R){
X.push_back(0);
}else{
X.push_back(2);
}
}
int ans = 0;
int bestIndx = -1;
for(int i = 0; i < N; i ++){
vector<int> Y;
for(int j: X){
Y.push_back(j);
}
/*for(int j: Y){
printf("%d", j);
}
printf("\n");
printf("i=%d\n", i);*/
int temp = 0;
for(int j = 0; j < C; j ++){
int max1 = 0;
for(int k = S[j]; k <= E[j]; k ++){
max1 = max(max1, Y[k]);
}
for(int k = S[j]; k <= E[j]; k ++){
Y.erase(Y.begin()+S[j]);
}
temp += (max1 == 1);
Y.insert(Y.begin()+S[j], max1);
/*for(int j: Y){
printf("%d", j);
}
printf("\n");*/
}
//printf("temp=%d\n", temp);
if(temp > ans){
ans = temp;
bestIndx = i;
}
if(i+1 < N){
swap(X[i], X[i+1]);
}
}
return bestIndx;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |