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 "prize.h"
#include <cassert>
// #include <iostream>
#include <vector>
using namespace std;
int find_best(int n) {
int high = n; // not possible
int low = 0; // possible
while (high - low > 1) {
int mid = low + (high - low) / 2;
vector<int> res = ask(mid);
int left = res.at(0);
int right = res.at(1);
assert(left + right <= 1);
if (left + right == 0) {
high = mid + 1; // not possible, because 'current' is the answer
low = mid; // possible
} else if (left == 1) {
high = mid; // not possible, because answer is to the left
} else if (right == 1) {
low = mid + 1; // possible, because answer is to the right
}
}
return low;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |