제출 #70641

#제출 시각아이디문제언어결과실행 시간메모리
70641polyfishGap (APIO16_gap)C++14
86.31 / 100
131 ms9232 KiB
//I love armpit fetish #include <bits/stdc++.h> #include "gap.h" using namespace std; #define debug(x) cerr << #x << " = " << x << '\n'; #define BP() cerr << "OK!\n"; #define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';} #define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';} #define FILE_NAME "data" const long long INF = 1e18; const int MAX_N = 100002; int n; long long a[MAX_N]; void Find(long long l, long long r, long long &u, long long &v) { long long *mn = new long long; long long *mx = new long long; MinMax(l, r, mn, mx); u = *mn; v = *mx; } long long solve_subtask_1() { int l = 1, r = n; long long s = 1, t = INF; while (l<=r) { long long mn, mx; Find(s, t, mn, mx); a[l] = mn; a[r] = mx; s = mn + 1; t = mx - 1; ++l; --r; } long long res = 0; for (int i=2; i<=n; ++i) res = max(res, a[i] - a[i-1]); return res; } long long solve_subtask_2() { long long l, r; Find(1, INF, l, r); long long B = (r - l) / (n - 1) + ((r - l) % (n - 1) != 0); long long cur = l + 1; long long res = B; long long _prev = l; while (cur<=r) { long long mn, mx; Find(cur, cur+B, mn, mx); if (mn==-1) { cur += B + 1; } else { res = max(res, mn - _prev); cur = mx + 1; _prev = mx; } } return res; } long long findGap(int testID, int N) { n = N; if (testID==1) return solve_subtask_1(); else return solve_subtask_2(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...