# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
403033 | CursedCode | Gap (APIO16_gap) | C++14 | 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>
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
using namespace std;
typedef long long lld;
lld findGap(int T, int N)
{
if (T == 1){
lld p = 0, q = (lld)1e18 + 1;
vector <lld> arr;
while(true){
lld mn, mx;
MinMax(p+1, q-1, &mn, &mx);
arr.pb(mn); arr.pb(mx);
if (mn == mx || sz(arr) == N) break;
p = mn, q = mx;
}
sort(all(arr));
lld ans = 0;
for (int i=1;i<sz(arr);i++)
ans = max(ans, arr[i]-arr[i-1]);
return ans;
}
}
return 0;
}