Submission #721957

#TimeUsernameProblemLanguageResultExecution timeMemory
721957Magikarp4000Gap (APIO16_gap)C++17
100 / 100
70 ms1940 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; #define INF int(1e9+7) #define FOR(i,s,n) for (int i = s; i < n; i++) #define FORR(i,n,s) for (int i = n; i > s; i--) #define FORX(u, arr) for (auto u : arr) #define ln '\n' #define ll long long #define PII pair<int, int> #define PLL pair<ll, ll> #define ALL(v) v.begin(), v.end() #define PB push_back #define F first #define S second const ll LLINF = 1e18+1; #define int long long int findGap(int32_t sub, int32_t n) { if (sub == 1) { int l = -1, r = 2e18; vector<int> a(n,-1); FOR(i,0,(n+1)/2) { MinMax(l+1,r-1,&l,&r); a[i] = l; a[n-i-1] = r; } int res = 0; FOR(i,0,n-1) res = max(res, a[i+1]-a[i]); return res; } else { int mi = 0, ma = 1e18; MinMax(mi,ma,&mi,&ma); if (n == 2) return ma-mi; int d = ma-mi; int block = d%(n-1) == 0 ? d/(n-1) : d/(n-1)+1; int l = mi, x, y, old = mi, cnt = 0; int res = 0; while (cnt < n-1) { MinMax(l,l+block,&x,&y); if (x != -1) { res = max(res, x-old); old = y; } cnt++; l += block+1; } return res; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...