Submission #268619

#TimeUsernameProblemLanguageResultExecution timeMemory
268619PlurmThe Big Prize (IOI17_prize)C++11
0 / 100
1351 ms8096 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; vector<int> memoiz[200005]; vector<int> customAsk(int x){ // Memoized version of ask if(memoiz[x].empty()) return memoiz[x] = ask(x); else return memoiz[x]; } int solve(int l, int r, int offsL = 0, int offsR = 0){ if(l == r) return -1; int m = (l+r)/2; vector<int> res = customAsk(m); do{ if(res[0] + res[1] == 0) return m; if(m == r) break; m++; }while(res[0] + res[1] < 500); int left = -1; if(res[0] - offsL > 0) left = solve(l, m-1, offsL, res[1]); if(m == r) return left; if(left != -1) return left; if(res[1] - offsR > 0) return solve(m+1, r, res[0], offsR); return -1; } int find_best(int n) { if(n < 5000){ for(int i = 0; i < n; i++) { vector<int> res = customAsk(i); if(res[0] + res[1] == 0) return i; } } return solve(0, n-1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...