제출 #242220

#제출 시각아이디문제언어결과실행 시간메모리
242220shenxy마상시합 토너먼트 (IOI12_tournament)C++11
0 / 100
18 ms768 KiB
#include <algorithm> #include <vector> using namespace std; int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) { if (N > 5000) return 0; vector<int> adjlist[N + C], stuff; for (int i = 0; i < N; ++i) stuff.push_back(i); for (int i = 0; i < C; ++i) { for (int j = S[i]; j <= E[i]; ++j) adjlist[N + i].push_back(stuff[S[i]]), stuff.erase(stuff.begin() + S[i]); stuff.insert(stuff.begin() + S[i], N + i); } int dptable[N + C], ans = -1, mx = -1; for (int i = 0; i < N; ++i) { int sm = 0; fill_n(dptable, N + C, -1); for (int j = 0; j < N; ++j) { if (j < i) dptable[j] = K[j]; else if (j == i) dptable[j] = R; else dptable[j] = K[j - 1]; } for (int j = N; j < N + C; ++j) { dptable[j] = -1; for (int k: adjlist[j]) dptable[j] = max(dptable[j], dptable[k]); if (dptable[j] == R) ++sm; } if (sm > mx) sm = mx, ans = i; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...