제출 #89235

#제출 시각아이디문제언어결과실행 시간메모리
89235zoomswk커다란 상품 (IOI17_prize)C++17
20 / 100
46 ms560 KiB
#include "prize.h" #include <vector> #include <algorithm> using namespace std; int m, res; void solve(int l, int r, int num){ 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; return; } int b = mid; while(resp[0]+resp[1] != m && b < r){ b++; resp = ask(b); if(resp[0]+resp[1] == 0){ res = mid; return; } } if(resp[0]+resp[1] == m){ solve(l, mid-1, resp[0]-(b-mid)); solve(b+1, r, resp[1]); } else{ solve(l, mid-1, num); } return; } int find_best(int n) { if(n <= 3000){ for(int i=0; i<n; i++){ vector<int> resp = ask(i); if(resp[0]+resp[1] == 0) return i; } } vector<int> resp; for(int i=0; i<500; i++){ resp = ask(i); if(resp[0]+resp[1] == 0) return i; m = max(m, resp[0]+resp[1]); } solve(0, n-1, m); return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...