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 <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
int find_best(int n) {
int pos = 0;
while (1) {
vi pos_res = ask(pos);
if (pos_res[0] + pos_res[1] == 0) {
return pos;
}
int l = pos, r = n;
while (r - l > 1) {
int mid = (l + r) >> 1;
vi mid_res = ask(mid);
if (pos_res[0] == mid_res[0] && pos_res[1] == mid_res[1]) {
l = mid;
} else {
r = mid;
}
}
pos = l + 1;
}
// can't be here
for (int i = 0; i < n; i++) {
vi res = ask(i);
if(res[0] + res[1] == 0)
return i;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |