Submission #405449

#TimeUsernameProblemLanguageResultExecution timeMemory
405449dxz05The Big Prize (IOI17_prize)C++14
20 / 100
16 ms12120 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 5e5 + 3e2; typedef long long ll; mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); int foo, hoo; vector<int> asked_values[MAXN]; int calls_count = 0; void ASK(int i){ vector<int> res; if (asked_values[i].empty()){ assert(calls_count < 10000); calls_count++; res = ask(i); //cout << i << ' ' << res.front() << ' ' << res.back() << endl; } else res = asked_values[i]; foo = res.front(); hoo = res.back(); asked_values[i] = res; } int find_best(int n) { int mx = 0; for (int i = 0; i < min(n, 500); i++){ ASK(i); if (foo + hoo == 0) return i; mx = max(mx, foo + hoo); } int cur = 0; for (int i = 0; i < n; i++){ int l = i, r = n - 1; int nxt = n; while (l <= r){ int m = (l + r) >> 1; ASK(m); if (foo + hoo == 0) return m; if (foo + hoo < mx){ nxt = m; foo -= cur; if (foo == 0) break; r = m - 1; continue; } if (foo > cur){ r = m - 1; } else l = m + 1; } i = nxt; ASK(i); cur = foo + 1; } assert(false); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...