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;
#pragma GCC optimize ("Ofast")
#define all(x) x.begin() , x.end()
#define sze(x) (ll)(x.size())
typedef long long ll;
const ll maxn = 1e5 + 17 , md = 1e9 + 7;
ll a[maxn] , mn , mx;
ll findGap(int T , int n){
if(T == 1 || n <= 8){
ll x = 0 , y = n , pn = 0 , px = 1e18;
while(x < y){
MinMax(pn , px , &mn , &mx);
a[x++] = mn; a[--y] = mx;
pn = mn + 1; px = mx - 1;
}
ll ans = 0;
for(ll i = 0 ; i < n - 1 ; i++){
ans = max(ans , a[i + 1] - a[i]);
}
return ans;
}
MinMax(0 , (ll)1e18 , &mn , &mx);
ll ls = mx;
ll cur = (mx - mn + n - 2) / (n - 1) , x = mn;
while(ls - x > cur){
ll l = x + 1 , r = l + (cur << 1);
MinMax(l , r , &mn , &mx);
if(mn == -1){
cur <<= 1;
} else {
cur = max(cur , mn - x);
x = mn;
}
}
return cur;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |