Submission #64593

#TimeUsernameProblemLanguageResultExecution timeMemory
64593nvmdavaThe Big Prize (IOI17_prize)C++17
20 / 100
131 ms5820 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; vector<int> ans[210000]; int mx = -1, ll, rr, Q = -1; int find(int l, int r){ if(Q != -1){ return 0; } if(ans[l][0] == ans[r][0]){ return 0; } if(ll > r || rr < l){ return 0; } int m = (l + r) >> 1, L = m, R = m + 1; while(l < L){ if(L < ll){ break; } ans[L] =ask(L); if(ans[L][0] + ans[L][1] == mx){ break; } if(ans[L][0] + ans[L][1] == 0){ Q = L; return L; } if(ans[L][0] == 0){ ll = L + 1; break; } L--; } while(r > R){ if(R > rr){ break; } ans[R] =ask(R); if(ans[R][0] + ans[R][1] == mx){ break; } if(ans[R][0] + ans[R][1] == 0){ Q = R; return R; } if(ans[R][1] == 0){ rr = R - 1; break; } R++; } return max(find(l, L), find(R, r)); } int find_best(int n) { ll = 0; rr = n - 1; for(int i = 0; i < 448; i++){ ans[i] = ask(i); if(ans[i][0] + ans[i][1] == 0){ return i; } mx = max(mx, ans[i][0] + ans[i][1]); } int l = 0, r = n - 1; while(true){ if(ans[l][0] + ans[l][1] == mx){ break; } l++; } while(true){ ans[r] = ask(r); if(ans[r][0] + ans[r][1] == mx){ break; } if(ans[r][0] + ans[r][1] == 0){ return r; } r--; } return find(l, r); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...