# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
406346 | p_square | 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<bits/stdc++.h>
#include "gap.h"
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define ll long long
#define mp make_pair
#define se second
#define fi first
using namespace std;
ll findGap(ll t, ll n)
{
ll a[n];
ll l = 0, r = 1e18+1;
ll ptr1, ptr2;
for(int i = 0; 2*i<n; i++)
{
MinMax(l, r, &ptr1, &ptr2);
a[2*i] = ptr1;
if(2*i < n-1)
a[2*i+1] = ptr2;
l = ptr1 + 1;
r = ptr2 - 1;
}
sort(a, a+n);
ll ma = 0;
for(int i = 1; i<n; i++)
{
ma = max(ma, a[i]-a[i-1]);
}
return ma;
}