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 res = -1;
int c = 0;
int find_best(int n) {
int current = 0;
int val = ask(current)[1];
if(val == 0)return 0;
int rk = val;
while(true){
int l = 0;
int r = n;
while(r-l > 0){
int m = (r+l)/2;
if(m == l+1){
l++;
break;
}
vector<int> ans = ask(m);
int v = ans[0]+ans[1];
if(v == 0){
res = m;
break;
}
if(ans[1] == 0){
n = m;
r = m;
}
if(ans[1] == val && v ==rk){
l = m;
}else if(v == rk){
r = m;
}
if(v != rk){
r = m;
}
}
if(res !=-1)break;
current = l;
vector<int> ans = ask(current);
int v = ans[0]+ans[1];
if(v == 0){
res = current;
break;
}
rk = v;
val = ans[1];
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |