# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
330485 | maximath_1 | The Big Prize (IOI17_prize) | C++11 | 125 ms | 512 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 <vector>
using namespace std;
int find_best(int n) {
int loli = -1, mx = 0, pre = 0;
for(int i = 0; i < 474; i ++){
vector<int> v = ask(i);
if(v[0] + v[1] == 0) return i;
if(v[0] + v[1] > mx){
mx = v[0] + v[1];
loli = i;
pre = v[0];
}
}
for(;;){
int lf = loli + 1, rg = n - 1;
int ans;
for(int md; lf <= rg;){
md = (lf + rg) / 2;
vector<int> v = ask(md);
if(v[0] + v[1] == 0) return md;
if(v[0] + v[1] == mx && v[0] == pre) lf = md + 1;
else rg = md - 1;
if(v[0] + v[1] != mx) ans = md;
}
for(int i = ans; i < n; i ++){
vector<int> v = ask(i);
if(v[0] + v[1] == 0) return i;
if(v[0] + v[1] == mx){
loli = i; pre = v[0];
break;
}
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |