제출 #371231

#제출 시각아이디문제언어결과실행 시간메모리
371231Bill_00Gap (APIO16_gap)C++14
64.63 / 100
55 ms2028 KiB
#include "gap.h" #include <bits/stdc++.h> #define N 100005 typedef long long ll; using namespace std; ll a[N],mn,mx; long long findGap(int T, int n) { ll m1=0,m2=1e18,ans=0; if(T==1 || n<=10){ for(int i=1;i<=(n+1)/2;i++){ MinMax(m1,m2,&mn,&mx); a[i]=mn; a[n+1-i]=mx; m1=mn+1; m2=mx-1; } for(int i=1;i<n;i++){ ans=max(ans,a[i+1]-a[i]); } return ans; } else{ ll ans=1; MinMax(m1,m2,&mn,&mx); ll l=mn,r=mx; while(l!=r){ MinMax(l+1,l+ans,&mn,&mx); if(mx!=-1) l=mx; else{ ll y=ans; while(mn==-1){ y*=2; MinMax(l+1,l+y,&mn,&mx); } ans=max(ans,mn-l); l=mx; } } return ans; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...