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) {
vector<int> ans(N, 0);
for (int i = 0; i < N; i++){
vector<int> a;
a.reserve(N);
for (int j = 0; j < i; j++) a.push_back(K[j]);
a.push_back(R);
for (int j = i; j < N - 1; j++) a.push_back(K[j]);
for (int it = 0; it < C; it++){
int mx = 0;
for (int j = S[it]; j <= E[it]; j++){
mx = max(mx, a[j]);
}
if (mx == R) ans[i]++;
a[S[it]] = mx;
a.erase(a.begin() + S[it] + 1, a.begin() + E[it] + 1);
}
}
int pos = max_element(ans.begin(), ans.end()) - ans.begin();
return pos;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |