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>
#define sc second
#define fr first
#define mk make_pair
#define pb push_back
using namespace std;
const int N = (1e6 + 5);
const int inf = (1e9 + 7);
vector <int> res;
int mx,cur;
int find_best(int n) {
for (int i = 0; i < min(n,1000); i ++) {
res = ask(i);
int s = res[0] + res[1];
if (!s) return i;
if (s > mx) mx = s,cur = i;
}
while(1) {
res = ask(cur);
if (res[0] + res[1] == 0) return cur;
if (res[0] + res[1] != mx) {
cur ++;
continue;
}
int lf = res[0];
int rt = res[1];
int l = cur,r = n - 1;
while (r - l > 1) {
int m = (r + l) >> 1;
res = ask(m);
if (res[0] + res[1] == 0) return m;
if (res[0] == lf && res[1] == rt) l = m;
else r = m;
}
res = ask(r);
if (res[0] + res[1] == 0) return r;
if (res[0] == lf && res[1] == rt) l = r;
cur = l + 1;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |