Submission #655462

#TimeUsernameProblemLanguageResultExecution timeMemory
655462benjaminkleynGap (APIO16_gap)C++17
30 / 100
3082 ms1864 KiB
#include <bits/stdc++.h> #include "gap.h" using namespace std; typedef long long ll; ll a[100000]; ll findGap(int T, int N) { if (T == 1) { ll lo = 0, hi = 1000000000000000000; int l = 0, r = N - 1; while (l <= r) { MinMax(lo, hi, &a[l], &a[r]); lo = a[l++] + 1; hi = a[r--] - 1; } ll mx = 0; for (int i = 0; i < N; i++) mx = max(mx, a[i+1] - a[i]); return mx; } else { ll lo, hi; MinMax(0, 1e18, &lo, &hi); ll step = (hi - lo - 1) / (N - 1); ll ans = step, last = lo; for (int i = lo; i + step + 1 <= hi; i += step) { ll x, y; MinMax(i + 1, i + step + 1, &x, &y); if (x != -1) { ans = max(ans, x - last); last = y; } } return ans; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...