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 a ,b;
MinMax(0, INF, &a, &b);
if(t == 1){
if(n == 2)return b - a;
ll l = a;
ll r = b;
ll ans = -INF;
for(int i = 0;i<(n - 1) / 2;i++){
MinMax(l+1, r-1, &a, &b);
ans = max(ans, a - l);
ans = max(ans, r - b);
l = a;
r = b;
}
return ans;
}
ll l = a + 1;
ll r = b;
ll prev = a;
ll sz = (b - a) / n;
ll ans = sz;
while(l < r){
int z = min(r, l + sz);
MinMax(l, z, &a, &b);
l = z + 1;
ans = max(ans, a - prev);
if(b != -1)prev = b;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |