# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1207006 | jasonic | Gap (APIO16_gap) | C++20 | 0 ms | 0 KiB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastIO cin.tie(0); ios::sync_with_stdio(false)
ll findGap(int T, ll N) {
ll mn = 0, mx = 1e18;
queue<ll> left, right;
while(true) {
ll l, r;
MinMax(mn, mx, l, r);
if(l == r) {
left.push(l);
} else {
left.push(l);
right.push(r);
}
mn = l + 1;
mx = r - 1;
if(size(left) + size(right) == N) break;
}
vector<ll> a;
while(!left.empty()) {
a.push_back(left.front());
left.pop();
}
while(!right.empty()) {
a.push_back(right.front());
right.pop();
}
ll ans = 0;
for(int i = 1; i < N; i++) {
ans = max(ans, a[i] - a[i-1]);
}
return ans;
}