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 save[200000];
int ret;
int f(int i) {
if (save[i]!=-1) {
return save[i];
}
vector<int> v=ask(i);
if (v[0]==0&&v[1]==0) {
ret=i;
}
return save[i]=v[1];
}
int find_best(int n) {
ret=-1;
int now=0;
memset(save,-1,sizeof(save));
if (f(now)==0) {
return now;
}
while (1) {
int lo=now; //f(lo)!=0
int hi=n;
while (lo+1<hi) {
int mid=(lo+hi)/2;
if (f(mid)!=0) {
lo=mid;
}
else {
hi=mid;
}
if (ret!=-1) {
return ret;
}
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |