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"
using namespace std;
int find_best(int n) {
int N=2e5+5;
int lo=(int)sqrt(N);
int maxx=0;
for(int i=0;i<lo;i++)
{
vector<int> tr=ask(i);
int t=tr[0]+tr[1];
if(t==0)
return i;
maxx=max(maxx,t);
}
int nasao=0;
int last=n-1;
while(true)
{
int l=last,r=last;
while(l<r)
{
int m=(l+r+1)>>1;
vector<int> tr=ask(m);
int t=tr[0]+tr[1];
if(t==0)
return m;
if(t!=maxx)
{
l=m;
continue;
}
if(tr[1]>nasao)
l=m+1;
else
r=m-1;
}
vector<int> tr=ask(l);
int t=tr[0]+tr[1];
if(t==0)
return l;
last=l-1;
nasao++;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |