# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
54024 | chpipis | The Big Prize (IOI17_prize) | C++11 | 87 ms | 1428 KiB |
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;
typedef vector<int> vi;
int num_q;
map<int, vi> memo;
vi query(int x) {
if (memo.count(x)) return memo[x];
num_q++;
vi ret = ask(x);
return memo[x] = ret;
}
int find_best(int n) {
memo.clear();
num_q = 0;
int mx = -1;
for (int i = 0, j; i < n; i = j + 1) {
if (i == n - 1) return i;
j = i;
vi cur = query(i);
if (cur[0] + cur[1] == 0) return i;
if (cur[0] + cur[1] < mx) continue;
mx = max(mx, cur[0] + cur[1]);
int lo = i + 1, hi = n - 1;
while (lo <= hi) {
int mid = (lo + hi) >> 1;
vi now = query(mid);
if (now[0] + now[1] == 0) return mid;
if (now == cur) {
lo = mid + 1;
j = mid;
} else {
hi = mid - 1;
}
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |