Submission #708581

#TimeUsernameProblemLanguageResultExecution timeMemory
708581yuuhiGap (APIO16_gap)C++14
30 / 100
44 ms1864 KiB
#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] ; int N ; 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) { N = 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 { return compute(0 , 1e18) ; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...