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;
vector <vector <int> > mp (maxn, vector <int> {-1, -1});
vector <int> get (int x) {
return mp[x] = ((mp[x] == vector <int> {-1, -1}) ? ask(x) : mp[x]);
}
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;
}
}
int i = 0;
int have = 0;
while (i < n) {
int l = i, r = n - 1, rs = -1;
while (l <= r) {
int mid = (l + r) / 2;
vector <int> k = get(mid);
if (k[0] + k[1] == 0) return mid;
if (k[0] - have > 0) {
r = mid - 1;
rs = mid;
}
else {
l = mid + 1;
}
}
if (rs == -1) i++;
else {
have++;
i = rs + 1;
}
}
assert(0);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |