제출 #256835

#제출 시각아이디문제언어결과실행 시간메모리
256835AM1648Gap (APIO16_gap)C++17
30 / 100
81 ms1916 KiB
/* be name khoda */ #include <bits/stdc++.h> #include "gap.h" using namespace std; typedef long long ll; typedef pair<ll, ll> pii; #define forifrom(i, s, n) for (ll i = s; i < n; ++i) #define fori(i, n) forifrom(i, 0, n) #define F first #define S second // ------------------------------------------------------------------ const ll maxn = 100010; const ll maxa = 1000000000000000000; ll A[maxn]; long long findGap(int T, int N) { if (T == 1) { A[0] = -1; A[N + 1] = maxa + 1; for (ll i = 0, j = N + 1; j - i > 1; ++i, --j) { MinMax(A[i] + 1, A[j] - 1, A + i + 1, A + j - 1); } ll ans = 0; forifrom (i, 1, N) ans = max(ans, A[i + 1] - A[i]); return ans; } else { ll lt, rt; MinMax(0, maxa, &lt, &rt); ll d = (rt - lt + N - 2) / (N - 1); ll i = lt, j = lt, best = d; while (j < rt) { ll a, b; MinMax(j + 1, min(j + d, rt - 1), &a, &b); if (a != -1) { best = max(best, a - i); i = j = b; } else { j += d; } } best = max(best, rt - i); return best; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...