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);
//int deleted = 0;
// for (int i=0;i<t.size();i++) cout << t[i] << " ";
// cout << endl;
for (int i=0;i<C;i++){
int winner = t[S[i]];
for (int j=S[i];j<=E[i];j++){
winner = max(winner,t[j]);
}
if (winner == R) wins++;
// cout << S[i] << " " << E[i] << endl;
// cout << "winner: " << winner << endl;
t[S[i]] = winner;
for (int j=E[i]+1;j<N;j++){
t[S[i] + j - E[i]] = t[j];
}
// deleted += E[i] - S[i];
// for (int j=0;j<t.size() - deleted;j++) cout << t[j] << " ";
// cout << endl;
}
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... |