# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
975492 | pirhosig | The Big Prize (IOI17_prize) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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]};
auto qres = ask(n - 1);
ii b = {qres[0], qres[1]};
return solve(0, n - 1, a, b);
}