#include<bits/stdc++.h>
#include "prize.h"
using namespace std;
int i,j,n,m,l,r,c,xl,xr,maz,rez;
vector<int> xx;
int find_best(int n)
{
l=0;
r=n-1;
rez=0;
maz=0;
while (true)
{
//cout << l << " " << r << "\n";
while (l<r)
{
c=l+(r-l)/2;
//cout << l << " " << c << " " << r << " " << maz << "\n";
xx=ask(c);
xl=xx[0];
xr=xx[1];
if (xl+xr==0)
{
return c;
}
if (xl+xr>maz)
{
l=0;
r=n-1;
rez=0;
maz=xl+xr;
}
else if (xl>rez)
{
r=c-1;
}
else
{
l=c+1;
}
}
xx=ask(l);
xl=xx[0];
xr=xx[1];
if (xl+xr==0)
{
return l;
}
rez++;
l++;
//cout << l << " " << r << "\n";
xx=(ask(l));
xl=xx[0];
xr=xx[1];
if (xl+xr==0)
{
return l;
}
while (xl+xr<maz&&l<=n-1)
{
l++;
rez++;
//cout << l << " " << r << "\n";
xx=(ask(l));
xl=xx[0];
xr=xx[1];
if (xl+xr==0)
{
return l;
}
}
if (xl+xr>maz)
{
maz=xl+xr;
l=0;
r=n-1;
rez=0;
}
r=n-1;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
292 KB |
Output is correct |
2 |
Correct |
2 ms |
312 KB |
Output is correct |
3 |
Correct |
3 ms |
388 KB |
Output is correct |
4 |
Correct |
3 ms |
388 KB |
Output is correct |
5 |
Correct |
2 ms |
388 KB |
Output is correct |
6 |
Correct |
3 ms |
388 KB |
Output is correct |
7 |
Correct |
3 ms |
388 KB |
Output is correct |
8 |
Correct |
3 ms |
472 KB |
Output is correct |
9 |
Correct |
2 ms |
472 KB |
Output is correct |
10 |
Correct |
2 ms |
496 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
496 KB |
Output is correct |
2 |
Correct |
2 ms |
520 KB |
Output is correct |
3 |
Correct |
2 ms |
540 KB |
Output is correct |
4 |
Correct |
3 ms |
556 KB |
Output is correct |
5 |
Correct |
3 ms |
556 KB |
Output is correct |
6 |
Correct |
3 ms |
560 KB |
Output is correct |
7 |
Correct |
3 ms |
560 KB |
Output is correct |
8 |
Correct |
3 ms |
560 KB |
Output is correct |
9 |
Correct |
3 ms |
560 KB |
Output is correct |
10 |
Correct |
3 ms |
560 KB |
Output is correct |
11 |
Correct |
11 ms |
560 KB |
Output is correct |
12 |
Correct |
3 ms |
560 KB |
Output is correct |
13 |
Correct |
8 ms |
560 KB |
Output is correct |
14 |
Correct |
5 ms |
560 KB |
Output is correct |
15 |
Correct |
14 ms |
560 KB |
Output is correct |
16 |
Partially correct |
92 ms |
560 KB |
Partially correct - number of queries: 6998 |
17 |
Correct |
3 ms |
560 KB |
Output is correct |
18 |
Partially correct |
108 ms |
560 KB |
Partially correct - number of queries: 8213 |
19 |
Correct |
4 ms |
560 KB |
Output is correct |
20 |
Correct |
19 ms |
560 KB |
Output is correct |
21 |
Incorrect |
130 ms |
560 KB |
Integer 200000 violates the range [0, 199999] |
22 |
Halted |
0 ms |
0 KB |
- |