Submission #89250

#TimeUsernameProblemLanguageResultExecution timeMemory
89250zoomswkThe Big Prize (IOI17_prize)C++17
20 / 100
68 ms576 KiB
#include "prize.h" #include <vector> #include <algorithm> using namespace std; int m, res; bool flag = false; void solve(int l, int r, int num, int bef){ if(num == 0) return; if(l > r) return; int mid = (l+r)/2; vector<int> resp = ask(mid); if(resp[0]+resp[1] == 0){ res = mid; flag = true; return; } int b = mid; while(resp[0]+resp[1] != m && b < r){ b++; resp = ask(b); if(resp[0]+resp[1] == 0){ res = b; flag = true; return; } } if(resp[0]+resp[1] == m){ solve(l, mid-1, resp[0]-(b-mid)-bef, bef); if(flag) return; solve(b+1, r, num-(resp[0]-bef), resp[0]); if(flag) return; } else{ solve(l, mid-1, num, bef); } return; } int find_best(int n) { if(n <= 5000){ for(int i=0; i<n; i++){ vector<int> resp = ask(i); if(resp[0]+resp[1] == 0) return i; } } vector<int> resp; int cnt=0; for(int i=0; i<480; i+=n/500){ resp = ask(i); if(resp[0]+resp[1] == 0) return i; m = max(m, resp[0]+resp[1]); } solve(0, n-1, m, 0); return res; }

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:48:9: warning: unused variable 'cnt' [-Wunused-variable]
     int cnt=0;
         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...