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;
//#define int long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using ll = long long;
using ld = long double;
const int N = 1e5 + 5;
const int M = 405;
const int SQRT = 500;
const int LOG = 20;
const ll INF = 1e18;
const int MOD = 1e9+7;
const ld EPS = 1e-9;
ll findGap(int t, int n){
ll mn ,mx;
MinMax(0, INF, &mn, &mx);
if(t == 1){
if(n == 2)return mx - mn;
ll l = mn;
ll r = mx;
ll ans = -INF;
for(int i = 0;i<(n - 1) / 2;i++){
MinMax(l+1, r-1, &mn, &mx);
ans = max(ans, mn - l);
ans = max(ans, r - mx);
l = mn;
r = mx;
}
return ans;
}
ll l = mn + 1;
ll r = mx;
ll prev = mn;
ll step = (mx - mn) / n;
ll ans = step;
while(l < r){
int nex = min(r, l + step);
MinMax(l, nex, &mn, &mx);
l = nex + 1;
ans = max(ans, mn - prev);
if(mx != -1)prev = mx;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |