#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> ask(int i);
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] == 0){
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] == 0){
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] == 0){
ans = ll;
return;
}
}
}
int find_best(int n) {
nn = n;
int lol = 0;
for(int i = 0; i < 480; i++) {
res[i] = ask(i);
if(res[i][0] + res[i][1] == 0)
return i;
if(big <= res[i][0] + res[i][1]){
big = res[i][0] + res[i][1];
lol = i + 1;
}
}
res[0] = query(0);
res[nn + 1] = query(nn + 1);
find(lol, nn + 1);
return ans - 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
16 ms |
9856 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
16 ms |
9996 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |