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 <bits/stdc++.h>
#include "prize.h"
using namespace std;
int nr[] = {1, 2, 5, 26, 677};
int vmx = 0, vpos = 0;
const int maxn = 2e5 + 2;
int pref [maxn];
int mark [maxn];
void upd (int x) {
mark[x] = 1;
for (int i = x; i < maxn; i++){
pref[i]++;
}
}
int find_best(int n) {
for (int i = 0; i < min(500, n); i++){
vector <int> k = ask(i);
if (k[0] + k[1] > vmx) {
vmx = k[0] + k[1];
vpos = i;
}
}
for (int i = 0; i < vmx; i++){
int l = 0, r = n - 1;
while (l <= r) {
int mid = (l + r) / 2;
// cout << i << " " << l << " " << r << "\n";
vector <int> k = ask(mid);
if (k[0] + k[1] == 0) return mid;
if (k[0] + k[1] != vmx && !mark[mid]) {
// cout << mid << "\n";
upd(mid);
break;
}
if (k[0] - pref[mid]) {
r = mid - 1;
}
else {
l = mid + 1;
}
}
}
// assert(0);
return -1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |