제출 #708605

#제출 시각아이디문제언어결과실행 시간메모리
708605yuuhiGap (APIO16_gap)C++14
30 / 100
62 ms1876 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< long long , long long > ii ; const int maxN = 1e5 + 10 ; long long a[maxN] ; long long res ; 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 { MinMax(0 , 1e18 , &a[1] , &a[n]) ; long long lent = (a[n] - a[1] - 1) / (n - 1) + 1 ; long long ans = lent ; for (long long l = a[1] , r = 0 ; l < a[n] ;) { if (r <= l) r = l + lent ; long long lo , hi ; MinMax(l + 1 , r , &lo , &hi) ; if (lo == -1) { r += lent ; } else { if (lo == hi) ans = max(ans , hi - l) ; l = hi ; r = l + lent ; } } return ans ; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...