제출 #32036

#제출 시각아이디문제언어결과실행 시간메모리
32036imeimi2000Gap (APIO16_gap)C++14
0 / 100
69 ms7360 KiB
#include "gap.h" #include <algorithm> using namespace std; typedef long long llong; int n; const llong m = 1e18; pair<llong, llong> ps[200000]; llong divpro(llong s, llong t) { if (n == 0) return t - s; llong ret = 0; llong q = (t - s - 1) / n; llong r = (t - s - 1) - q * n; llong pree = s; for (int i = 0, j = s; i < n; ++i) { llong dis = q + (i < r); MinMax(j + 1, j + dis, &ps[i].first, &ps[i].second); j += dis; if (ps[i].first == -1) continue; ret = max(ret, ps[i].first - pree); pree = ps[i].second; } return max(ret, t - pree); } long long findGap(int T, int N) { n = N; llong s, t; MinMax(0, m, &s, &t); n -= 2; if (T == 1) { llong ret = 0; llong i = s, j = t; while (n > 0) { MinMax(i + 1, j - 1, &i, &j); n -= 2; ret = max(ret, max(t - j, i - s)); s = i; t = j; } return ret; } else { return divpro(s, t); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...