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<bits/stdc++.h>
#include "prize.h"
//#include "grader.cpp"
using namespace std;
vector<int>GLOB;
int find_best(int n){
int CNT=0;
for(int i=0;i<min(n,500);i++){
vector<int>R=ask(i);
CNT=max(CNT,R[0]+R[1]);
}
int FOUND=0,LAST=0;
while(1){
int L=LAST,R=n-1,mid,BEST=-1;
while(1){
vector<int>z=ask(L);
if(z[0]+z[1]==0)
return L;
if(z[0]+z[1]!=CNT)
L++;
else
break;
}
while(L<=R){
mid=(L+R)/2;
vector<int>z=ask(mid);
int A=z[0],B=z[1];
if(A+B!=CNT)
BEST=mid;
if(A>FOUND)
R=mid-1;
else if(!A&&!B)
return mid;
else
L=mid+1;
}
if(BEST==-1)
exit(1);
LAST=BEST+1;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |