# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
975821 | Isam | Gap (APIO16_gap) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define int long long
constexpr int sz = 1e5 + 5;
int a[sz];
int findGap(int T, int N){
memset(a, -1, sizeof(a));
int mn, mx;
MinMax(0ll, (int)1E18, &mn, &mx);
a[1] = mn, a[N] = mx;
for(register int i = 2; i <= N/2 + (N & 1); ++i){
int l = a[i-1], r = a[N - i + 1];
MinMax(l+1, r-1, &mn, &mx); // called by reference
a[i] = mn, a[N - i + 1] = mx;
}
int ans = -inf;
for(register int i = 2; i <= N; ++i){
ans = min(ans, a[i] - a[i-1]);
}
return ans;
}
signed main(){
ios_base::sync_with_stdio(0), cin.tie(0);
}