Submission #874207

#TimeUsernameProblemLanguageResultExecution timeMemory
874207MatjazJousting tournament (IOI12_tournament)C++14
17 / 100
1066 ms1884 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...