제출 #536176

#제출 시각아이디문제언어결과실행 시간메모리
536176mario05092929Gap (APIO16_gap)C++17
30 / 100
51 ms1864 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; ll a[100005]; int lp,rp; long long findGap(int T, int N) { ll n = N; ll l = 0, r = 1e18,mn,mx; if(T & 1) { MinMax(l,r,&mn,&mx); lp = 1, rp = n; while(1) { a[lp++] = mn; a[rp--] = mx; l = mn+1, r = mx-1; if(lp > rp) break; MinMax(l,r,&mn,&mx); } ll mxx = 0; for(int i = 1;i < n;i++) { mxx = max(mxx,a[i+1]-a[i]); } return mxx; } else { MinMax(l,r,&mn,&mx); ll diff = 0; ll len = (mx-mn+1)/n+2; ll st = mn+1; ll tmn,tmx; for(int i = 1;i <= n;i++) { MinMax(st,st+len-1,&tmn,&tmx); if(tmn == -1) continue; diff = max(diff,tmn-mn); mn = tmx; st += len; } return diff; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...