# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
713259 | tht2005 | The Big Prize (IOI17_prize) | C++17 | 81 ms | 336 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"
int find_best(int n) {
int big = 0;
std::vector<int> q_big(2, -1);
for(int i = 0; i < n && i < 500; ++i) {
std::vector<int> q = ask(i);
if(q[0] == 0 && q[1] == 0) {
return i;
}
if(q_big[0] + q_big[1] <= q[0] + q[1]) {
big = i;
q_big = q;
}
}
while(big + 1 < n) {
int l = big + 1, r = n - 1;
while(l <= r) {
int mid = (l + r) >> 1;
std::vector<int> q = ask(mid);
if(q[0] + q[1] < q_big[0] + q_big[1] || q[1] < q_big[1]) {
r = mid - 1;
}
else {
big = mid;
l = mid + 1;
}
}
for(int i = big + 1; i < n; ++i) {
std::vector<int> q = ask(i);
if(q[0] == 0 && q[1] == 0) {
return i;
}
if(q[0] + q[1] == q_big[0] + q_big[1]) {
big = i;
q_big = q;
break;
}
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |