Submission #708575

#TimeUsernameProblemLanguageResultExecution timeMemory
708575yuuhiGap (APIO16_gap)C++14
43.01 / 100
76 ms2792 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 ; vector< long long > v ; void compute (long long lo , long long hi) { if (lo > hi || _size(v) >= N) return ; long long l , r ; MinMax(lo , hi , &l , &r) ; if (l == -1) return ; v.push_back(l) ; if (l != r) v.push_back(r) ; lo = l + 1 ; hi = r - 1 ; if (lo > hi) return ; long long mid = (lo + hi) >> 1 ; compute(lo , mid) ; compute(mid + 1 , hi) ; } 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 { compute(0 , 1e18) ; sort(v.begin() , v.end()) ; for (int i = 0 ; i < n ; ++ i) a[i + 1] = v[i] ; long long ans = 0 ; for (int i = 1 ; i < n ; ++ i) ans = max(ans , a[i + 1] - a[i]) ; return ans ; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...