Submission #520695

#TimeUsernameProblemLanguageResultExecution timeMemory
520695d4xnThe Big Prize (IOI17_prize)C++17
20 / 100
74 ms344 KiB
#include "prize.h" #include <vector> using namespace std; int search(int l, int r) { if (l > r) return -1; if (l == r) { vector<int> ans = ask(l); if (ans[0] == 0 && ans[1] == 0) return l; return -1; } int m = (l+r)/2; vector<int> ans = ask(m); if (ans[0] == 0 && ans[1] == 0) return m; if (ans[0] == 0) { return search(m+1, r); } else if (ans[1] == 0) { return search(l, m-1); } else { int ans1, ans2; ans1 = search(l, m-1); ans2 = search(m+1, r); return (ans1 == -1 ? ans2 : ans1); } return -1; } int find_best(int n) { return search(0, n-1); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...