#include"prize.h"
#include<bits/stdc++.h>
using namespace std;
int ans = -1;
bool check(vector<int> res) {
return (res[0] == res[1] && res[0] == 0);
}
void calc(int l, int r) {
if (l == r || ans != -1) {
return;
}
int m = (l+r)/2;
vector<int> seg1l, seg1r, seg2l, seg2r;
seg1l = ask(l);
seg1r = ask(m);
seg2l = ask(m+1);
seg2r = ask(r);
if (check(seg1l)) {
ans = l;
}
if (check(seg1r)) {
ans = m;
}
if (check(seg2l)) {
ans = m+1;
}
if (check(seg2r)) {
ans = r;
}
if (seg1l != seg1r) {
calc(l, m);
}
if (seg2l != seg2r) {
calc(m+1, r);
}
}
int find_best(int n) {
calc(0, n-1);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
428 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
344 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
1 ms |
428 KB |
Output is correct |
4 |
Correct |
1 ms |
344 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
344 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
11 |
Correct |
4 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
344 KB |
Output is correct |
13 |
Correct |
8 ms |
344 KB |
Output is correct |
14 |
Correct |
4 ms |
344 KB |
Output is correct |
15 |
Correct |
11 ms |
344 KB |
Output is correct |
16 |
Incorrect |
38 ms |
344 KB |
Incorrect |
17 |
Halted |
0 ms |
0 KB |
- |