#include "prize.h"
#include "iostream"
using namespace std;
int find_best(int n) {
int mx = 0;
for (int i = 0; i < min(n, 600); i ++) {
auto pr = ask(i);
mx = max(mx, pr[0] + pr[1]);
}
int ls = 0;
for (; ls < n;) {
for (; ls < n; ls ++) {
auto pr = ask(ls);
int sm = pr[0] + pr[1];
if (sm == mx) break;
if (0 == sm)
return ls;
}
int ps = ask(ls)[1];
int rs = n;
while (ls != rs) {
int mi = ls + (rs - ls) / 2;
auto pr = ask(mi);
int sm = pr[0] + pr[1];
if (sm != mx) rs = mi - 1;
if (0 == ps - pr[1]) ls = mi;
else rs = mi - 1;
}
ls ++;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
50 ms |
344 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
48 ms |
344 KB |
Incorrect |
2 |
Halted |
0 ms |
0 KB |
- |