이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
//#include "grader.cpp"
pair <int, int> memo[200001];
int ans;
pair <int, int> get (int x) {
if (memo[x].first != -1) {
return memo[x];
}
auto h = ask(x);
pair <int, int> g = {h[0], h[1]};
if (g.first + g.second == 0) {
ans = x;
}
return memo[x] = g;
}
void solve (int l, int r) {
if (l == r) {
get(l);
return;
}
auto less = [&] (int x, int y) -> bool {
return get(x).first + get(x).second < get(y).first + get(y).second;
};
while (less(l, r) || less(r, l)) {
while (less(l, r)) l++;
while (less(r, l)) r--;
}
if (get(l).second == get(r).second) {
return;
}
int mid = (l + r) / 2;
solve(l, mid); solve(mid, r);
}
int find_best (int n) {
ans = -1;
for (int i = 0; i < n; i++) {
memo[i] = {-1, -1};
}
solve(0, n - 1);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |