Submission #261431

#TimeUsernameProblemLanguageResultExecution timeMemory
261431srvltGap (APIO16_gap)C++14
0 / 100
85 ms1260 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pb push_back #define all(x) begin(x), end(x) #define SZ(x) (int)(x).size() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #include "gap.h" ll findGap(int T, int N) { ll MAX = 1e18, mn = 0, mx = 0; MinMax(0ll, MAX, & mn, & mx); if (T == 1) { ll l = mn, r = mx; ll ans = 1; while (true) { if (l + 1 > r - 1) break; MinMax(l + 1, r - 1, & mn, & mx); if (mn == -1) break; ans = max(ans, mn - l); ans = max(ans, r - mx); l = mn, r = mx; } ans = max(ans, r - l); return ans; } ll step = (mx - mn) / (N - 1), v = mn, f = mx; ll ans = 1; while (v < f) { MinMax(v + 1, v + step, & mn, & mx); if (mn == -1) step *= 2; else { ans = max(ans, mn - v); v = mx; if (step > (mx - mn) / (N - 1)) step /= 2; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...