#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;
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 |
1 |
Incorrect |
89 ms |
296 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
49 ms |
588 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |