#include "prize.h"
#include<bits/stdc++.h>
using namespace std;
int gg(int a, int b){if(a==0)return b;return a;}
int f(int l, int r)
{
if(l>r)return 0;
int m=l+r>>1;
vector<int>v=ask(m);
if(v[0]==0&&v[1]==0)return m;
if(v[1]==0)return f(l, m-1);
if(v[0]==0)return f(m+1, r);
return gg(f(l, m-1), f(m+1, r));
}
int find_best(int n)
{
return f(0, n-1);
}
Compilation message
prize.cpp: In function 'int f(int, int)':
prize.cpp:8:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
8 | int m=l+r>>1;
| ~^~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
492 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Incorrect |
118 ms |
364 KB |
Incorrect |
12 |
Halted |
0 ms |
0 KB |
- |