#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
int find_best(int n){
vector<int>a(2);
vector<int>vb(n,0);
int x=0,y=n-1,z,xx=0,yy=n-1,p;
int c=9877;
while(x!=y){
z=(xx+yy)/2;
p=z;
if(vb[z]){
z++;
while(vb[z]){
z++;
if(z>yy){
z=xx;
}
}
if(p==z){
if(yy==y){
y=xx+1;
yy=y;
}
if(xx==x){
x=yy-1;
xx=x;
}
z=xx;
while(vb[z]){
x++;
xx++;
z++;
}
}
}
a=ask(z);
vb[z]=1;
if(a[0]+a[1]==0){
return z;
}
else if(a[1]+a[0]==1){
if(a[1]){
x=z+1;
}
else{
y=z-1;
}
xx=x;
yy=y;
}
else{
a[0]=(9347*c)%a[0];
a[1]=(9347*c)%a[1];
if(a[0]<a[1]){
xx=x;
yy=z-1;
}
else{
xx=z+1;
yy=y;
}
}
}
return x;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1112 KB |
Output is correct |
3 |
Correct |
1 ms |
1112 KB |
Output is correct |
4 |
Correct |
1 ms |
1204 KB |
Output is correct |
5 |
Correct |
1 ms |
1112 KB |
Output is correct |
6 |
Correct |
1 ms |
1112 KB |
Output is correct |
7 |
Correct |
1 ms |
1112 KB |
Output is correct |
8 |
Correct |
1 ms |
1108 KB |
Output is correct |
9 |
Correct |
1 ms |
1112 KB |
Output is correct |
10 |
Correct |
1 ms |
1112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1112 KB |
Output is correct |
2 |
Correct |
1 ms |
1112 KB |
Output is correct |
3 |
Correct |
1 ms |
1112 KB |
Output is correct |
4 |
Correct |
1 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
1112 KB |
Output is correct |
6 |
Correct |
1 ms |
1112 KB |
Output is correct |
7 |
Correct |
1 ms |
1112 KB |
Output is correct |
8 |
Correct |
1 ms |
1112 KB |
Output is correct |
9 |
Correct |
1 ms |
1112 KB |
Output is correct |
10 |
Correct |
1 ms |
1112 KB |
Output is correct |
11 |
Runtime error |
1 ms |
2136 KB |
Execution killed with signal 8 |
12 |
Halted |
0 ms |
0 KB |
- |