#include "prize.h"
// #include "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
int find_best(int n) {
vector<pii> cur, nxt;
cur.emplace_back(0, n-1);
while (!cur.empty()) {
nxt.clear();
sort(cur.begin(), cur.end(), [&] (pii& a, pii& b) {
int sza = a.second-a.first;
int szb = b.second-b.first;
if (sza != szb) return sza < szb;
return a.first < b.first;
});
for (auto& p : cur) {
int l = p.first, r = p.second;
if (l == r) {
vector<int> res = ask(l);
if (res[0] == 0 && res[1] == 0) {
return l;
}
} else {
int m = (l + r) / 2;
vector<int> res = ask(m);
if (res[0] == 0 && res[1] == 0) {
return m;
} else if (res[0] == 1 && res[1] == 0) {
nxt.emplace_back(l, m);
} else if (res[0] == 0 && res[1] == 1) {
nxt.emplace_back(m+1, r);
} else {
nxt.emplace_back(l, m);
nxt.emplace_back(m+1, r);
}
}
}
swap(cur, nxt);
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
248 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
392 KB |
Output is correct |
5 |
Correct |
2 ms |
308 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
248 KB |
Output is correct |
8 |
Correct |
2 ms |
248 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
392 KB |
Output is correct |
2 |
Correct |
2 ms |
312 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
508 KB |
Output is correct |
6 |
Correct |
2 ms |
248 KB |
Output is correct |
7 |
Correct |
2 ms |
308 KB |
Output is correct |
8 |
Correct |
2 ms |
388 KB |
Output is correct |
9 |
Correct |
2 ms |
248 KB |
Output is correct |
10 |
Correct |
2 ms |
248 KB |
Output is correct |
11 |
Incorrect |
104 ms |
376 KB |
Incorrect |
12 |
Halted |
0 ms |
0 KB |
- |