# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
403029 | 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
using namespace std;
long long findGap(int T, long long N){
long long p = 0, q = (lld)1e18 + 1;
vector <long long> a;
while(true){
long long m1, m2;
MinMax(p + 1, q - 1, &m1, &m2);
a.pb(m1); a.pb(m2);
if (m1 == m2 || a.size() == N) break;
p = m1, q = m2;
}
sort(a.begin(),a.end());
long long ans = 0;
for (int i = 1;i < sz(a);i++)
ans = max(ans, a[i] - a[i - 1]);
return ans;
}