| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 106950 | golub | Gap (APIO16_gap) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second
#define pb push_back
#define pii pair<int, int>
#define int long long
#define len(x) (long long)x.size()
template<typename A, typename B>
bool cmax(A &a, const B &b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template<typename A, typename B>
bool cmin(A &a, const B &b) {
if (a > b) {
a = b;
return true;
}
return false;
}
int askcount = 0;
pii ask(int x) {
askcount++;
int mn = 0, mx = 0;
MinMax(x, x, &mn, &mx);
return {mn, mx};
}
long long findGap(int T, int N) {
int best_dist = 0;
int cur_value = 0;
while (true) {
if (askcount >= (N + 1) / 2) break;
pii res = ask(cur_value + best_dist + 1);
if (res.S == cur_value) cmax(best_dist, res.F - res.S);
cur_value = res.F;
if (res.F == -1) return best_dist;
}
return best_dist;
}
