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<set>
using namespace std;
const int MAXN = 2e5 + 8;
int ans;
int prf[MAXN];
set<int> s[MAXN];
bool dnc(int l, int r) {
if (l > r) return false;
int m = (l + r) >> 1;
vector<int> a = ask(m);
int sum = a[0] + a[1];
prf[m] = a[0];
if (sum == 0) { ans = m; return true; }
auto it = s[sum].insert(m).first;
if (it == s[sum].begin() ? a[0] : prf[*prev(it)] != prf[m])
if (dnc(l, m - 1)) return true;
if (next(it) == s[sum].end() ? a[1] : prf[m] != prf[*next(it)])
if (dnc(m + 1, r)) return true;
return false;
}
int find_best(int N) {
dnc(0, N - 1);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |