#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);
if (xl+xr==0)
{
return l;
}
rez++;
l++;
//cout << l << " " << r << "\n";
xx=(ask(l));
xl=xx[0];
xr=xx[1];
while (xl+xr<maz)
{
l++;
rez++;
//cout << l << " " << r << "\n";
xx=(ask(l));
xl=xx[0];
xr=xx[1];
}
if (xl+xr>maz)
{
maz=xl+xr;
l=0;
r=n-1;
rez=0;
}
r=n-1;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
440 KB |
Output is correct |
3 |
Correct |
2 ms |
440 KB |
Output is correct |
4 |
Incorrect |
4 ms |
440 KB |
Integer 200000 violates the range [0, 199999] |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
3 ms |
524 KB |
Integer 200000 violates the range [0, 199999] |
2 |
Halted |
0 ms |
0 KB |
- |