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"
using namespace std;
#include "gap.h"
#ifndef EVAL
#include "grader.cpp"
#endif
#define ar array
typedef long long ll;
const ll inf = 1e18;
ll findGap(int t, int n){
if(t == 1){
ll l = 0, r = inf, mn, mx;
vector<ll> a;
for(int i=0;i<=n/2 && (int)a.size() < n;i++){
MinMax(l, r, &mn, &mx);
if(mn == -1) break;
a.push_back(mn);
a.push_back(mx);
l = mn + 1, r = mx - 1;
}
sort(a.begin(), a.end());
ll res = 0;
for(int i=1;i<(int)a.size();i++){
res = max(res, a[i] - a[i-1]);
}
return res;
}
ll l = 0, r = inf, mn, mx;
MinMax(l, r, &mn, &mx);
ll B = (mx - mn + n - 1) / n, last = mn, R = mx;
ll res = B;
for(l=mn, r=l+B;last<R;l=r+1, r=l+B){
MinMax(l, r, &mn, &mx);
if(mn == -1) continue;
res = max(res, mn - last);
last = mx;
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |