Submission #405332

#TimeUsernameProblemLanguageResultExecution timeMemory
405332dxz05The Big Prize (IOI17_prize)C++14
20 / 100
22 ms12168 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]; void ASK(int i){ vector<int> res = (!asked_values[i].empty() ? asked_values[i] : ask(i)); foo = res.front(); hoo = res.back(); asked_values[i] = res; } int find_best(int n) { int mn = 0; for (int i = 0; i < 1000; i++){ int x = rng() % n + 1; ASK(x); if (foo + hoo == 0) return x; mn = min(mn, foo + hoo); } for (int i = 0; i < n; i++){ int l = i, r = n - 1; int idx = n; while (l <= r){ int m = (l + r) >> 1; ASK(m); if (foo + hoo == 0) return m; if (foo + hoo < mn) idx = m; if (foo){ r = m - 1; } else l = m + 1; } i = idx + 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...