제출 #536183

#제출 시각아이디문제언어결과실행 시간메모리
536183mario05092929Gap (APIO16_gap)C++17
30 / 100
42 ms1848 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+1; ll mnn = mn; ll st = mnn+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-mnn); mnn = tmx; st += len; } return diff; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...