#include <bits/stdc++.h>
#include "prize.h"
using namespace std;
#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
int rek(int a, int b) {
int lo = a, hi = b;
while (lo <= hi + 5) {
int mid = (lo + hi) / 2;
vector<int> res = ask(mid);
if(res[0] + res[1] == 0) return mid;
if (res[0] && !res[1]) hi = mid - 1;
else if (!res[0] && res[1]) lo = mid + 1;
else {
int ret = rek(a, mid - 1);
if (ret != -1) return ret;
return rek(mid + 1, b);
}
}
return -1;
}
int find_best(int n) {
return rek(1, n);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |