Submission #372597

#TimeUsernameProblemLanguageResultExecution timeMemory
372597Bill_00Gap (APIO16_gap)C++14
64.88 / 100
58 ms2032 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=2; MinMax(m1,m2,&mn,&mx); if(mx-mn+1==n) return 1; 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...