#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
int find_best(int n) {
int lo = 0, hi = n - 1;
int last = INT_MAX;
while (1) {
int mid = (lo + hi) / 2;
vector<int> tmp = ask(mid);
if (tmp[0] + tmp[1] == 0) {
return mid;
}
if (tmp[0] + tmp[1] < last) {
last = tmp[0] + tmp[1];
lo = 0, hi = n - 1;
}
if (tmp[0] > tmp[1]) {
hi = mid - 1;
} else {
lo = mid + 1;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
444 KB |
Output is correct |
3 |
Correct |
2 ms |
444 KB |
Output is correct |
4 |
Correct |
2 ms |
444 KB |
Output is correct |
5 |
Correct |
2 ms |
496 KB |
Output is correct |
6 |
Correct |
3 ms |
496 KB |
Output is correct |
7 |
Correct |
2 ms |
516 KB |
Output is correct |
8 |
Correct |
2 ms |
556 KB |
Output is correct |
9 |
Correct |
2 ms |
556 KB |
Output is correct |
10 |
Correct |
2 ms |
556 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
556 KB |
Output is correct |
2 |
Correct |
3 ms |
556 KB |
Output is correct |
3 |
Correct |
2 ms |
556 KB |
Output is correct |
4 |
Correct |
2 ms |
556 KB |
Output is correct |
5 |
Correct |
2 ms |
556 KB |
Output is correct |
6 |
Correct |
3 ms |
556 KB |
Output is correct |
7 |
Correct |
3 ms |
572 KB |
Output is correct |
8 |
Correct |
2 ms |
572 KB |
Output is correct |
9 |
Correct |
2 ms |
572 KB |
Output is correct |
10 |
Correct |
2 ms |
572 KB |
Output is correct |
11 |
Incorrect |
100 ms |
572 KB |
Incorrect |
12 |
Halted |
0 ms |
0 KB |
- |