Submission #81585

#TimeUsernameProblemLanguageResultExecution timeMemory
81585polyfishThe Big Prize (IOI17_prize)C++14
0 / 100
70 ms980 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; map<int, pair<int, int> > asked; vector<int> pos; int left_val(int x) { if (!asked.count(x)) { vector<int> tmp = ask(x); asked[x] = make_pair(tmp[0], tmp[1]); } return asked[x].first; } int right_val(int x) { if (!asked.count(x)) { vector<int> tmp = ask(x); asked[x] = make_pair(tmp[0], tmp[1]); } return asked[x].second; } void find_pos(int l, int r, int nPos) { if (l>r) return; int mid = (l + r) / 2; int tmp = mid; for (; mid>=l; --mid) { if (left_val(mid)+right_val(mid)==nPos) break; pos.push_back(mid); } if (mid>0) find_pos(l, mid-1, left_val(mid)); if (tmp+1<=r) find_pos(tmp+1, r, right_val(tmp)-(tmp-mid)); } int find_best(int n) { int l = -1, max_hist = 0; for (int i=0; i<min(n, 500); ++i) { if (left_val(i)+right_val(i)>max_hist) { max_hist = left_val(i) + right_val(i); l = i; } } find_pos(l, n-1, right_val(l)); for (auto v : pos) { if (left_val(v) + right_val(v) == 0) return v; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...