Submission #776425

#TimeUsernameProblemLanguageResultExecution timeMemory
776425benjaminkleynThe Big Prize (IOI17_prize)C++17
90 / 100
77 ms336 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; int find_best(int n) { int i = 0; vector<int> cur = ask(i); for (int j = 0; j < n && j < 500; j++) { vector<int> res = ask(j); if (res[0] + res[1] == 0) return j; if (res[0] + res[1] > cur[0] + cur[1]) i = j, cur = res; } while (i < n) { for (int j = 18; j >= 0; j--) if (i + (1 << j) < n) { vector<int> res = ask(i + (1 << j)); if (res[0] == cur[0] && res[1] == cur[1]) i += (1 << j); } while (i < n) { vector<int> res = ask(++i); if (res[0] + res[1] == 0) return i; if (cur[0] + cur[1] == res[0] + res[1]) { cur = res; break; } } } return n - 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...