Submission #288122

#TimeUsernameProblemLanguageResultExecution timeMemory
288122emanIaicepsaJousting tournament (IOI12_tournament)C++14
17 / 100
1082 ms1408 KiB
#pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx,fma,sse,sse2,sse3,avx2") #include<bits/stdc++.h> #define mem(x,i) memset(x,i,sizeof(x)) #define dbg(x) cerr<<#x<<" = "<<x<<'\n'; using namespace std; int arr[5005], newarr[5005], l[5005], r[5005], n, lgn, c; int solve(int x){ int ans = 0, p = arr[x]; for(int i=1;i<=n;i++) newarr[i] = arr[i]; int siz = n; for(int i=1;i<=c;i++){ bool used = 0; int mxid = l[i]; used |= (newarr[mxid] == p); for(int j=l[i]+1;j<=r[i];j++){ used |= (newarr[j] == p); if(newarr[j] > newarr[mxid]){ newarr[mxid] = -1; mxid = j; } else newarr[j] = -1; } if(newarr[mxid] == p) ans++; else if(used) return ans; int idx = 1; for(int i=1;i<=siz;i++){ if(newarr[i] != -1) newarr[idx++] = newarr[i]; } siz = idx; } return ans; } int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) { n = N; c = C; arr[1] = R; for(int i=2;i<=n;i++) arr[i] = K[i-2]; for(int i=1;i<=c;i++) l[i] = S[i-1]+1, r[i] = E[i-1]+1; int ans = 0, cur = solve(1); for(int i=1;i<n;i++){ swap(arr[i], arr[i+1]); int x = solve(i+1); if(x > cur) ans = i, cur = x; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...