Submission #577200

#TimeUsernameProblemLanguageResultExecution timeMemory
577200Justin1Jousting tournament (IOI12_tournament)C++14
49 / 100
152 ms1620 KiB
#include <bits/stdc++.h> #define f first #define s second using namespace std; int ar[5005]; pair<int,int> range[5005]; int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) { for (int i = 0; i < N; i++) range[i] = {i,i}; for (int i = 0; i < C; i++) { range[S[i]].s = range[E[i]].s; for (int j = E[i]+1; j < N; j++) range[j-(E[i]-S[i])] = range[j]; E[i] = range[S[i]].s, S[i] = range[S[i]].f; } int ans = -1, pos = -1; for (int i = 0; i < N; i++) { int ptr = 0; for (int j = 0; j < i; j++) ar[ptr++] = K[j]; ar[ptr++] = R; for (int j = i; j < N; j++) ar[ptr++] = K[j]; int cnt = 0; int l = i, r = i; while (l && ar[l-1] < R) l--; while (r < N-1 && ar[r+1] < R) r++; for (int j = 0; j < C; j++) { bool ok = (S[j] <= i && i <= E[j]); ok &= (l <= S[j] && E[j] <= r); cnt += ok; } if (cnt > ans) { ans = cnt; pos = i; } } return pos; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...