#include "gap.h"
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int inf = 1e18;
long long findGap(int32_t t, int32_t n)
{
int mn, mx;
MinMax(0, inf, &mn, &mx);
int ds = mx-mn;
int kor = (ds+n-2)/(n-1);
int pr = mn, rez = kor, i;
int tr = 0, tmx = 0;
for (i = mn; i+kor < mx; i+=kor+1)
{
MinMax(i, i+kor, &tr, &tmx);
if (tr == -1) continue;
rez = max(rez, tr-pr);
pr = tmx;
}
MinMax(i, mx, &tr, &tmx);
if (mn != -1)
rez = max(rez, tr-pr);
return rez;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |