이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |