This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <assert.h>
#include "prize.h"
std::pair<int, int> query(int p) {
std::vector<int> r = ask(p);
return std::make_pair(r[0], r[1]);
}
int binsearch(int l, int r) {
assert(l < r);
if(l == r-1) return l;
int m = l + (r-l) / 2;
auto[lc, rc] = query(m);
if(lc == 0 && rc == 0) return m;
if(lc != 0) return binsearch(l, m);
else if(rc != 0) return binsearch(m+1, r);
else assert(false);
}
int find_best(int n) {
return binsearch(0, n);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |