Submission #875372

#TimeUsernameProblemLanguageResultExecution timeMemory
875372ZeroCoolGap (APIO16_gap)C++14
30 / 100
35 ms3360 KiB
#include <bits/stdc++.h> #include "gap.h" using namespace std; //#define int long long #define pb push_back #define mp make_pair #define mt make_tuple #define all(v) v.begin(), v.end() #define rall(v) v.rbegin(), v.rend() using ll = long long; using ld = long double; const int N = 1e5 + 5; const int M = 405; const int SQRT = 500; const int LOG = 20; const ll INF = 1e18; const int MOD = 1e9+7; const ld EPS = 1e-9; ll findGap(int t, int n){ ll mn ,mx; MinMax(0, INF, &mn, &mx); if(t == 1){ if(n == 2)return mx - mn; ll l = mn; ll r = mx; ll ans = -INF; for(int i = 0;i<(n - 1) / 2;i++){ MinMax(l+1, r-1, &mn, &mx); ans = max(ans, mn - l); ans = max(ans, r - mx); l = mn; r = mx; } return ans; } ll l = mn + 1; ll r = mx; ll prev = mn; ll step = (mx - mn) / n; ll ans = step; while(l < r){ int nex = min(r, l + step); MinMax(l, nex, &mn, &mx); l = nex + 1; ans = max(ans, mn - prev); if(mx != -1)prev = mx; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...