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"
#define f first
#define s second
#define double long double
#define _size(x) ((int)((x).size()))
using namespace std ;
typedef pair< int , int > ii ;
const int maxN = 1e5 + 10 ;
long long a[maxN] ;
long long res ;
long long compute (long long lo , long long hi) {
if (lo > hi) return -1 ;
// if (hi - lo < res) return 0 ;
long long l , r ;
MinMax(lo , hi , &l , &r) ;
if (l == -1) return -1 ;
lo = l + 1 ; hi = r - 1 ;
if (lo > hi) {
res = max(res , r - l) ;
return r - l ;
}
long long mid = (lo + hi) >> 1 ;
long long L = compute(lo , mid) ;
long long R = compute(mid + 1 , hi) ;
if (L == -1 && R == -1) {
res = max(res , r - l) ;
return r - l ;
}
return max(L , R) ;
}
long long findGap (int T , int n) {
if (T == 1) {
long long l = 0 , r = 1e18 ;
for (int i = 1 ; i <= (n + 1) / 2 ; ++ i) {
MinMax(l , r , &a[i] , &a[n - i + 1]) ;
l = a[i] + 1 ; r = a[n - i + 1] - 1 ;
}
long long ans = 0 ;
for (int i = 1 ; i < n ; ++ i) ans = max(ans , a[i + 1] - a[i]) ;
return ans ;
}
else {
compute(0 , 1e18) ;
return res ;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |