제출 #228549

#제출 시각아이디문제언어결과실행 시간메모리
228549NightlightGap (APIO16_gap)C++14
0 / 100
3098 ms1176 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; const long long maxa = 1e18; long long diff, mn, mx, T, N; long long mntp, mxtp, ans = 0, last; void solve1() { MinMax(1, maxa, &mn, &mx); for(int i = 3; i <= N; i += 2) { MinMax(mn + 1, mx - 1, &mntp, &mxtp); ans = max(ans, mntp - mn); ans = max(ans, mxtp - mx); mn = mntp, mx = mxtp; } ans = max(ans, mx - mn); } void solve2() { MinMax(1, maxa, &mn, &mx); if(N == 2) { ans = mx - mn; return; } long long seg = (mx - mn) / (N - 2); last = mn; for(int i = mn + 1; i < mx; i += seg) { MinMax(i, min(i + seg - 1, mx - 1), &mntp, &mxtp); if(mntp != -1) { ans = max(ans, mntp - last); last = mxtp; } } ans = max(ans, mx - last); } long long findGap(int a0, int b1) { T = a0, N = b1; if(T == 1) { solve1(); }else solve2(); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...