Submission #96239

#TimeUsernameProblemLanguageResultExecution timeMemory
96239xplus2g4Gap (APIO16_gap)C++11
0 / 100
2076 ms5368 KiB
#include <algorithm> #include "gap.h" using namespace std; typedef long long ll; #define MAX 1e18 long long findGap(int T, int N){ ll a[N]; int c=0; if(T==1){ MinMax(0,MAX,&a[0],&a[N-1]); c++; while(a[c-1]<a[N-c]){ MinMax(a[c-1]+1,a[N-c]-1,&a[c],&a[N-c-1]); c++; } c=N; } else { ll mn, mx; MinMax(0,MAX,&mn,&mx); ll d=(mx-mn)/(N-1),x,y; a[c++]=mn; for(int i=mn+1; i<mx; i+=d+1){ MinMax(i,i+d,&x,&y); if(x!=-1){ a[c++]=x; a[c++]=y; } } a[c++]=mx; } ll ans=0; for(int i=1; i<c; i++){ ans = max(ans, a[i]-a[i-1]); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...