Submission #132707

#TimeUsernameProblemLanguageResultExecution timeMemory
132707TalantThe Big Prize (IOI17_prize)C++17
90 / 100
103 ms504 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,500); 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...