제출 #221353

#제출 시각아이디문제언어결과실행 시간메모리
221353zoooma13Gap (APIO16_gap)C++14
72.60 / 100
61 ms1956 KiB
#include "bits/stdc++.h" #include "gap.h" using namespace std; long long MAX_A = 1e18; long long findGap(int T, int N){ if(N <= 20 || T == 1){ vector <long long> A(N); MinMax(0 ,1e18 ,&A[0] ,&A[N-1]); for(int i=1; i<(N+1)/2; i++) MinMax(A[i-1]+1 ,A[N-i]-1 ,&A[i] ,&A[N-i-1]); long long ret = 1; for(int i=1; i<N; i++) ret = max(ret ,A[i]-A[i-1]); return ret; } long long lst = 0, mx_dist = 1; if(N <= 60) MinMax(0 ,1e18 ,&lst ,&MAX_A); else for(long long mn ,mx ,d=1; ; d<<=1){ MinMax(0 ,d ,&mn ,&mx); if(mn != -1){ lst = mn; break; } } for(int ok=1; ok; ) { for(long long mn,mx ,nxt=mx_dist+1; ok; nxt<<=1){ MinMax(lst+1 ,min(MAX_A ,lst+nxt) ,&mn ,&mx); if(lst+nxt >= MAX_A) ok = 0; if(mn != -1){ mx_dist = max(mx_dist ,mn-lst); lst = mx; break; } } } return mx_dist; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...