이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "prize.h"
using namespace std;
int find_best(int n) {
//binary search the first element each time
map<int, int> hi;
hi[n-1] = 0;
int last = 0;
auto a = ask(0);
if (a[0] + a[1] == 0) return 0;
for (auto k: hi) {
if (k.first > a[0] + a[1])hi[k.first]++;
}
while (true) {
int i1 = last;
int i2 = n - 1;
while (i1 != i2) {
int middle = (i1 + i2) / 2;
auto a = ask(middle);
if (a[0] + a[1] == 0) return middle;
if (a[0] - hi[a[0] + a[1]] == 0) {
i1 = middle+1;
} else {
i2 = middle - 1;
}
}
auto a = ask(i1);
if (a[0] + a[1] == 0) return i1;
last = i1;
for (auto k: hi) {
if (k.first > a[0] + a[1])hi[k.first]++;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |