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>
#include <algorithm>
using namespace std;
int GetBestPosition(int N, int C, int R, int *K, int *S, int *E)
{
int best_p = -1;
int rounds = -1;
for(int p = 0; p < N; p++)
{
// cerr << "\n\n\n\n p= " << p << '\n';
int this_ans = 0;
vector<int> original;
for(int i = 0; i < p; i++) original.push_back(K[i]);
original.push_back(R);
for(int i = p; i < N-1; i++) original.push_back(K[i]);
// for(int o: original) cerr << o << ' ';
// cerr << '\n';
vector<int> nw;
for(int c = 0; c < C; c++)
{
// cerr << S[c] << ' ' << E[c] << " -> ";
nw.clear();
original.clear();
for(int i = 0; i < S[c]; i++) nw.push_back(original[i]);
int y = -1;
for(int i = S[c]; i <= E[c]; i++) y = max(y, original[i]);
if(y == R) this_ans++;
nw.push_back(y);
for(int i = E[c]+1; i < N; i++) nw.push_back(original[i]);
swap(original, nw);
// cerr << "! ";
// for(int o: original) cerr << o << ' ';
// cerr << '\n';
}
if(this_ans > rounds)
{
rounds = this_ans;
best_p = p;
}
// cerr << p << ' ' << this_ans << '\n';
}
return best_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... |