Submission #742493

#TimeUsernameProblemLanguageResultExecution timeMemory
742493vjudge1Gap (APIO16_gap)C++17
0 / 100
3099 ms1136 KiB
#include <algorithm> #include <iostream> #include <iomanip> #include <bitset> #include <cmath> #include <queue> #include <map> #include <set> #include "gap.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; #define ent "\n" const int maxn = 2e3 + 100; const ll INF = (1ll<<61); const int MOD = 1e9 + 7; const int inf = (1<<30); const int maxl = 20; const int P = 31; ll findGap(int t, int n){ if(t == 1){ ll l = -1; ll r = 1e18 + 1; ll ans = 0; while(true){ ll tl, tr; MinMax(l + 1, r - 1, &tl, &tr); if(tl == -1) break; if(l != -1){ ans = max(ans, tl - l); ans = max(ans, r - tr); } l = tl; r = tr; } if(l < r) ans = max(ans, r - l); return ans; } else{ ll mn, mx, ans = 0; MinMax(0, 1e18, &mn, &mx); ll d = (mx - mn) / (n - 1); ll x = (mx - mn) % (n - 1); ll p = -1; for(ll i = mn; i <= mx;){ ll r = i + d + bool(x--); ll tl, tr; MinMax(i, r - 1, &tl, &tr); if(tl == -1) continue; if(p != -1) ans = max(ans, tl - p); p = tr; i = r; } return ans; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...