#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
int ll = 0, rr = 0;
int f(int l, int r){
if(l > r)return -1;
int m = (l+r)/2;
vector<int> v = ask(m);
if(v[0] == 0)ll = l;
if(v[1] == 1)rr = r;
if(v[0] == 0 && v[1] == 0)return m;
if(v[1] > v[0]){
int x = f(max(m+1,ll),min(r,rr));
if(x != -1)return x;
}
return f(max(l,ll),min(m-1,rr));
}
int find_best(int n) {
rr = n-1;
return f(0,n-1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
292 KB |
Output is correct |
3 |
Correct |
1 ms |
288 KB |
Output is correct |
4 |
Correct |
1 ms |
208 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
288 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
260 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
296 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
1 ms |
288 KB |
Output is correct |
5 |
Correct |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
296 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
272 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Incorrect |
61 ms |
208 KB |
Incorrect |
12 |
Halted |
0 ms |
0 KB |
- |