Submission #975493

#TimeUsernameProblemLanguageResultExecution timeMemory
975493pirhosigThe Big Prize (IOI17_prize)C++17
0 / 100
2371 ms1048576 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; typedef pair<int, int> ii; int solve(int low, int upp, ii a, ii b) { while (a.first + a.second != b.first + b.second) { if (a.first + a.second < b.first + b.second) { low++; auto qres = ask(low); a.first = qres[0]; a.second = qres[1]; if (a.second + a.first == 0) return low; } else { upp--; auto qres = ask(upp); b.first = qres[0]; b.second = qres[1]; if (b.first + b.second == 0) return upp; } } if (a.first == b.first) return 0; int mid = (low + upp) / 2; return solve(low, mid, a, b) + solve(mid, upp, a, b); } int find_best(int n) { auto qres = ask(0); ii a = {qres[0], qres[1]}; qres = ask(n - 1); ii b = {qres[0], qres[1]}; return solve(0, n - 1, a, b); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...