#include<bits/stdc++.h>
#include "gap.h"
using namespace std;
const long long MAXN = 2e5 + 10;
long long a[MAXN];
long long findGap(int T, int N)
{
if(T == 1)
{
long long s = 0, t = (long long)(1e18);
long long mn, mx;
long long n = N;
long long filled0 = 0, filled1 = n+1;
while(filled0 + 1 <= filled1 - 1)
{
MinMax(s, t, &mn, &mx);
if(mn == mx)
{
filled0 ++;
a[filled0] = mn;
n --;
break;
}
filled0 ++;
filled1 --;
n-= 2;
a[filled0] = mn;
a[filled1] = mx;
s = mn + 1;
t = mx - 1;
}
long long ans = -1;
for (long long i = 2; i <= N; ++ i)
ans = max(ans, (long long) (a[i] - a[i-1]));
return ans;
}
long long n = N;
long long s = 0, t = (long long)(1e18);
long long mn, mx;
long long range_l = 0, range_r;
long long l;
MinMax(s, t, &mn, &mx);
range_l = mn;
range_r = mx;
l = range_r - range_l + 1;
long long x = l/n
long long last = range_l, cache = 0;
long long st = last;
long long ans = 0;
while(last < range_r)
{
s = last + 1;
t = last + x + 1;
MinMax(s, t, &mn, &mx);
if(mx != -1 && mn > last && (mn >= s && mn <= t) && (mx >= s && mx <= t))
{
ans = max(ans, mn - st);
last = mx;
st = last;
}
else
{
cache += x;
last = last + x;
}
}
return ans;
}
/**
2 5
2 3 7 17 19
*/
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:53:5: error: expected ',' or ';' before 'long'
53 | long long last = range_l, cache = 0;
| ^~~~
gap.cpp:54:20: error: 'last' was not declared in this scope; did you mean 'st'?
54 | long long st = last;
| ^~~~
| st
gap.cpp:71:13: error: 'cache' was not declared in this scope
71 | cache += x;
| ^~~~~