Submission #256836

#TimeUsernameProblemLanguageResultExecution timeMemory
256836AM1648Gap (APIO16_gap)C++17
100 / 100
61 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; while (j + 1 <= rt - 1) { ll a, b; MinMax(j + 1, min(j + d, rt - 1), &a, &b); if (a != -1) { d = max(d, a - i); i = j = b; } else { j += d; } } d = max(d, rt - i); return d; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...