#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> res[200005];
int ans;
int big, nn;
vector<int> query(int i){
if(i == 0)
return vector<int>({0, big});
if(i == nn + 1)
return vector<int>({big, 0});
return ask(i - 1);
}
void find(int l, int r){
if(ans) return;
if(res[l][0] == res[r][0]) return;
int ll, rr, m = (l + r) >> 1;
res[m] = query(m);
if(res[m][0] + res[m][1] == big){
find(l, m);
find(m, r);
return;
}
if(res[m][0] + res[m][1] == 1){
ans = m;return;
}
for(rr = m + 1; rr < r; rr++){
res[rr] = query(rr);
if(res[rr][0] + res[rr][1] == big){
find(rr, r);
break;
}
if(res[rr][0] + res[rr][1] == 1){
ans = rr;
return;
}
}
for(ll = m - 1; ll > l; ll--){
res[ll] = query(ll);
if(res[ll][0] + res[ll][1] == big){
find(l, ll);
break;
}
if(res[ll][0] + res[ll][1] == 1){
ans = ll;
return;
}
}
}
int find_best(int n) {
nn = n;
for(int i = 0; i < 500; i++) {
vector<int> res = ask(i);
if(res[0] + res[1] == 0)
return i;
big = max(big, res[0] + res[1]);
}
res[0] = query(0);
res[nn + 1] = query(nn + 1);
find(0, nn + 1);
return ans - 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
5120 KB |
Integer -1 violates the range [0, 199999] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
4992 KB |
Integer -1 violates the range [0, 199999] |
2 |
Halted |
0 ms |
0 KB |
- |