#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
int solve(int low, int upp, ii a, ii b) {
while (a.first + a.second != b.first + b.second) {
if (a.first + a.second < b.first + b.second) {
low++;
auto qres = ask(low);
a.first = qres[0];
a.second = qres[1];
if (a.second + a.first == 0) return low;
}
else {
upp--;
auto qres = ask(upp);
b.first = qres[0];
b.second = qres[1];
if (b.first + b.second == 0) return upp;
}
}
if (a.first == b.first) return 0;
int mid = (low + upp) / 2;
return solve(low, mid, a, b) + solve(mid, upp, a, b);
}
int find_best(int n) {
auto qres = ask(0);
ii a = {qres[0], qres[1]};
qres = ask(n - 1);
ii b = {qres[0], qres[1]};
return solve(0, n - 1, a, b);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2371 ms |
1048576 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
887 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |