# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
266596 | dCoding | 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>
using namespace std;
#define F0R(i,n) for(int i = 0; i < (n); i++)
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define ll long long
#define pb push_back
long long findGap(int T, int N) {
vector<ll> a;
ll lo = 0, hi = 1e18;
while(a.size() < N) {
ll mn,mx;
MinMax(lo,hi,mn,mx);
if(mn == mx) {
a.pb(mn);
} else {
a.pb(mn); a.pb(mx);
hi = mx-1; lo = mn+1;
assert(lo <= hi);
}
}
ll ans = 0;
sort(a.begin(),a.end());
FOR(i,1,n-1) ans = max(ans,a[i]-a[i-1]);
return ans;
}