#include <bits/stdc++.h>
using namespace std;
#include "prize.h"
//vector<int> ask(int i);
int N;
vector<int> memo[200001];
vector<int> query(int i) {
if(memo[i][0] != -1) return memo[i];
else return memo[i] = ask(i);
}
int find(int l, int r) {
if(l == r) return l;
int mid = (l+r)/2;
vector<int> q = query(mid);
if(q[0] == 0 and q[1] == 0) return mid;
else if(q[0] == 0) return find(mid+1, r);
return find(l, mid-1);
}
int find_best(int n) {
N = n;
for(int i = 0; i < N; i++) memo[i] = {-1, -1};
return find(0, N-1);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
11256 KB |
Output is correct |
2 |
Correct |
19 ms |
11316 KB |
Output is correct |
3 |
Correct |
19 ms |
11364 KB |
Output is correct |
4 |
Correct |
19 ms |
11364 KB |
Output is correct |
5 |
Correct |
19 ms |
11376 KB |
Output is correct |
6 |
Correct |
19 ms |
11516 KB |
Output is correct |
7 |
Correct |
19 ms |
11516 KB |
Output is correct |
8 |
Correct |
20 ms |
11516 KB |
Output is correct |
9 |
Correct |
19 ms |
11516 KB |
Output is correct |
10 |
Correct |
21 ms |
11516 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
11516 KB |
Output is correct |
2 |
Correct |
19 ms |
11516 KB |
Output is correct |
3 |
Correct |
19 ms |
11516 KB |
Output is correct |
4 |
Correct |
19 ms |
11516 KB |
Output is correct |
5 |
Correct |
19 ms |
11516 KB |
Output is correct |
6 |
Correct |
18 ms |
11524 KB |
Output is correct |
7 |
Correct |
19 ms |
11524 KB |
Output is correct |
8 |
Correct |
22 ms |
11524 KB |
Output is correct |
9 |
Correct |
19 ms |
11524 KB |
Output is correct |
10 |
Correct |
19 ms |
11524 KB |
Output is correct |
11 |
Incorrect |
19 ms |
11524 KB |
answer is not correct |
12 |
Halted |
0 ms |
0 KB |
- |