#include "gap.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
const long long INF = 1e17;
typedef long long ll;
const ll MOD = 1e9+7;
#define F first
#define pb push_back
#define S second
#define P pair
#define V vector
#define all(v) v.begin(), v.end()
long long findGap(int T, int N) {
ll l,r;
MinMax (0,1e18,&l,&r );
if (N==2) {
return r-l;
}
ll lb=l;
ll curr=l;
ll ans=0;
ll n=(ll)N;
ll bnd=((r-l)/(n-1))+1;
while (curr<=r) {
ll mn,mx;
MinMax(curr,curr +bnd-1,&mn,&mx);
if (curr==lb) {
if (mn!=mx) {
lb=mx;
curr+=bnd;
}
else
curr+=bnd;
}
else {
if (mn==-1) {
curr+=bnd;
}
else {
ans=max(ans,mn-lb);
lb=mx;
curr+=bnd;
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |