제출 #111373

#제출 시각아이디문제언어결과실행 시간메모리
111373diamond_dukeGap (APIO16_gap)C++11
30 / 100
85 ms1916 KiB
#include <algorithm> #include <cstdio> #include "gap.h" using ll = long long; ll arr[100005]; inline ll calc(int n) { ll res = 0; for (int i = 1; i < n; i++) res = std::max(res, arr[i] - arr[i - 1]); return res; } ll findGap(int sub, int n) { if (sub == 1) { for (int l = 0, r = n - 1; l <= r; l++, r--) { ll pre = l ? arr[l - 1] + 1 : 0; ll nxt = r + 1 < n ? arr[r + 1] - 1 : (ll)1e18; MinMax(pre, nxt, arr + l, arr + r); } return calc(n); } ll mn, mx, cnt = 0; MinMax(0, 1e18, &mn, &mx); ll blk = (mx - mn) / (n - 1); arr[cnt++] = mn; for (ll i = mn; i + blk <= mx; i += blk + 1) { ll x, y; MinMax(i, i + blk, &x, &y); if (~x) arr[cnt++] = x; if (x != y) arr[cnt++] = y; } arr[cnt++] = mx; return std::max(blk, calc(cnt)); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...