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"
using namespace std;
typedef long long ll;
const ll Inf = 1e18;
ll findGap(int Tc, int N){
assert(Tc == 2);
ll L, R, S, T;
MinMax(0ll, Inf, &L, &R);
ll D = (R - L) / (N - 1);
ll md = (R - L) % (N - 1);
ll pos = L;
ll st;
vector<ll> V;
for(int i = 0; i < N - 1; i++){
st = D;
if(i < md) st ++;
MinMax(pos, pos + st - 1, &S, &T);
if(S != -1){
V.push_back(S);
V.push_back(T);
}
pos += st;
}
sort(V.begin(), V.end());
ll ans = D + min(md, 1ll);
for(int i = 0; i + 1 < (int) V.size(); i++) ans = max(ans, V[i + 1] - V[i]);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |