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;
const int lim = 500;
int find_best(int n) {
if (n <= lim) {
for (int i = 0; i < n; i++) {
vector<int> res = ask(i);
if (res[0] + res[1] == 0) {
return i;
}
}
}
int mx = 0;
for (int i = 0; i < lim; i++) {
vector<int> res = ask(i);
if (res[0] + res[1] == 0) {
return i;
}
mx = max(mx, res[0] + res[1]);
}
int cur = lim;
while (true) {
vector<int> res1 = ask(cur);
if (res1[0] + res1[1] == 0) {
return cur;
}
if (res1[0] + res1[1] < mx) {
cur++;
continue;
}
int lt = cur + 1;
int rt = n - 2;
while (lt <= rt) {
int mt = (lt + rt) / 2;
vector<int> res2 = ask(mt);
if (res2[0] + res2[1] == 0) {
return mt;
}
if ((res2[0] + res2[1] == res1[0] + res1[1]) && (res2[0] == res1[0])) {
cur = mt;
lt = mt + 1;
}
else {
rt = mt - 1;
}
}
cur++;
}
return -1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |