This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/* Bismillahir Rahmanir Rahim */
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
const long long M = 1e18;
long long mdiff = 0;
void solve(long long st, long long en, long long n){
long long mn, mx;
MinMax(st, en, &mn, &mx);
long long rng = 1LL + (mx - mn) / (n - 1LL);
long long lst = mn;
for(long long i=mn+1;i<mx;i+=rng){
long long A, B;
MinMax(i, min(i + rng - 1LL, mx), &A, &B);
if(A == -1) continue;
if(lst != -1) mdiff = max(mdiff, A - lst);
lst = B;
}
if(lst != -1) mdiff = max(mdiff, mx - lst);
}
long long findGap(int T, int N){
solve(0, M, N);
return mdiff;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |