Submission #1149737

#TimeUsernameProblemLanguageResultExecution timeMemory
1149737vladiliusGap (APIO16_gap)C++20
86.31 / 100
44 ms1864 KiB
#include <bits/stdc++.h> #include "gap.h" using namespace std; using ll = long long; using pii = pair<int, int>; #define pb push_back #define ff first #define ss second const ll inf = 1e18; ll findGap(int T, int n){ if (T == 1){ ll l, r, s = 0, t = inf; vector<ll> a(n); for (int i = 0; i < (n + 1) / 2; i++){ MinMax(s, t, &l, &r); a[i] = l; a[n - i - 1] = r; s = l + 1; t = r - 1; } ll out = 0; for (int i = 0; i < (n - 1); i++){ out = max(out, a[i + 1] - a[i]); } return out; } ll l, r; MinMax(0, inf, &l, &r); if ((r - l + 1) == n) return 1; ll M = r, f = ceil(1.0 * (r - l) / (n - 1)) + 1, k = l, P = k, out = 0; while (k < M){ MinMax(k + 1, k + f, &l, &r); if (l == -1){ k += f; } else { out = max(out, l - P); P = k = r; } } out = max(out, (M - P)); return out; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...