# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
715475 | lmqzzz | The Big Prize (IOI17_prize) | C++14 | 81 ms | 208 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;
int lolipop = -1;
int best = -1;
int solve(int l, int r, int before_left) {
if (l >= r) return -1;
//[l, r)
int m = l + r >> 1;
// [l, m) [m + 1, r)
int lm = m - 1, rm = m;
int L, R;
while (rm < r) {
auto mid = ask(rm);
if (mid[0] + mid[1] == 0) return rm;
if (mid[0] + mid[1] == best) {
L = mid[0], R = mid[1];
break;
}
rm++;
}
if (rm == r) {
return solve(l, m, before_left);
} else {
return max(solve(l, m, before_left), solve(rm + 1, r, L));
}
}
int find_best(int n) {
const int LIM = 4;
vector<vector<int>> b(LIM);
for (int i = 0; i < LIM; i++) {
b[i] = ask(i);
if (best < b[i][0] + b[i][1]) {
best = b[i][0] + b[i][1];
lolipop = i;
}
if (b[i][0] + b[i][1] == 0) return i;
}
int cnt = 0;
for (int i = 0; i < LIM; i++) {
if (b[i][0] + b[i][1] < best) cnt++;
}
return solve(LIM, n, cnt);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |