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 <algorithm>
#include <iostream>
using namespace std;
int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) {
vector<int> p(K, K + N - 1);
p.push_back(R);
int best_position = N;
int best_wins = 0;
for (int tmp=N-1;tmp>=0;tmp--){
int wins = 0;
vector<int> t(p);
for (int i=0;i<C;i++){
int winner = t[S[i]];
for (int j=S[i];j<=E[j];j++){
winner = max(winner,t[j]);
}
if (winner == R) wins++;
t[S[i]] = winner;
for (int j=E[i]+1;j<N;j++){
t[S[i] + j - E[i]] = t[j];
}
}
if (wins >= best_wins){
best_wins = wins;
best_position = tmp;
}
//cout << tmp << " " << wins << endl;
if (tmp > 0) swap(p[tmp-1], p[tmp]);
}
return best_position;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |