Submission #221373

#TimeUsernameProblemLanguageResultExecution timeMemory
221373zoooma13Gap (APIO16_gap)C++14
89.04 / 100
81 ms2064 KiB
#include "bits/stdc++.h" #include "gap.h" using namespace std; long long findGap(int T, int N){ if(N <= 8 || 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 mn ,mx ,mx_dist = 1; MinMax(0 ,1e18 ,&mn ,&mx); long long d = (mx-mn)/(N-1) ,lst = mn; for(long long s,t,p=mn+1; p<mx; p+=d){ MinMax(p ,min(mx ,p+d)-1 ,&s ,&t); if(s != -1){ mx_dist = max(mx_dist ,s-lst); lst = t; } } return max(mx-lst ,mx_dist); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...