제출 #132704

#제출 시각아이디문제언어결과실행 시간메모리
132704Talant커다란 상품 (IOI17_prize)C++17
20 / 100
79 ms396 KiB
#include "prize.h" #include <bits/stdc++.h> #define sc second #define fr first #define mk make_pair #define pb push_back using namespace std; const int N = (1e6 + 5); const int inf = (1e9 + 7); vector <int> res; int mx,cur; int find_best(int n) { for (int i = 0; i < min(n,1000); i ++) { res = ask(i); int s = res[0] + res[1]; if (!s) return i; if (s > mx) mx = s,cur = i; } while(1) { res = ask(cur); if (res[0] + res[1] == 0) return cur; if (res[0] + res[1] != mx) { cur ++; continue; } int lf = res[0]; int rt = res[1]; int l = cur,r = n - 1; while (r - l > 1) { int m = (r + l) >> 1; res = ask(m); if (res[0] + res[1] == 0) return m; if (res[0] == lf && res[1] == rt) l = m; else r = m; } res = ask(r); if (res[0] + res[1] == 0) return r; if (res[0] == lf && res[1] == rt) l = r; cur = l + 1; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...