Submission #732996

#TimeUsernameProblemLanguageResultExecution timeMemory
732996SanguineChameleonGap (APIO16_gap)C++17
100 / 100
66 ms3188 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; long long findGap(int T, int N) { if (T == 1) { long long mi = 0; long long mx = 1e18L; int lt = 0; int rt = N - 1; vector<long long> a(N); while (lt <= rt) { MinMax(mi, mx, &mi, &mx); a[lt] = mi; a[rt] = mx; mi++; mx--; lt++; rt--; } long long res = 0; for (int i = 1; i < N; i++) { res = max(res, a[i] - a[i - 1]); } return res; } else { long long mi = 0; long long mx = 1e18L; MinMax(mi, mx, &mi, &mx); long long len = (mx - mi - 1) / (N - 1) + 1; vector<long long> a; a.push_back(mi); for (int i = 1; i <= N - 1; i++) { long long lt = mi + 1 + len * (i - 1); long long rt = mi + len * i; MinMax(lt, rt, &lt, &rt); if (lt != -1) { a.push_back(lt); a.push_back(rt); } } long long res = 0; for (int i = 1; i < (int)a.size(); i++) { res = max(res, a[i] - a[i - 1]); } return res; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...