# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
50998 | 2018-06-15T14:15:50 Z | Abelyan | Gap (APIO16_gap) | C++17 | 0 ms | 0 KB |
#include "grader.cpp" #include <bits/stdc++.h> using namespace std; void MinMax(long long, long long, long long*, long long*); typedef long long ll; const ll MX=(ll)1000000000000000000; const int MAXN=100006; ll a[MAXN]; long long findGap(int T, int n) { ll mx,mn; MinMax(0,MX,&mn,&mx); int j=n-1; int i=0; while (mn!=-1){ a[i]=mn; a[j]=mx; //cout<<i<<" "<<" "<<j<<endl; //cout<<mn<< " "<<mx<<endl; i++; j--; if (mn+1>mx-1) break; MinMax(mn+1,mx-1,&mn,&mx); if (mn==mx && mn!=-1){ a[i]=mn; break; } } ll maxim=0; for (int i=0;i<n-1;i++){ //cout<<a[i]<<endl; maxim=max(maxim,a[i+1]-a[i]); } return maxim; }