제출 #23450

#제출 시각아이디문제언어결과실행 시간메모리
23450ztrongGap (APIO16_gap)C++14
56.31 / 100
93 ms5144 KiB
#include <bits/stdc++.h> #include "gap.h" using namespace std; #define FOR(i, a, b) for (int i = a, _b = b; i <= _b; ++i) #define FORD(i, a, b) for (int i = a, _b = b; i >= _b; --i) #define REP(i, a) for (int i = 0, _a = a; i < _a; ++i) #define llint long long #define sz(x) (x.size()) #define LL(x) (x * 2) #define RR(x) (x * 2 + 1) #define fi first #define se second #define db(x) cout << #x << " = " << x << endl; #define BIT(x, i) ((x >> i) & 1) #define MASK(i) (1ll << i) #define times clock() * 1.0 / CLOCKS_PER_SEC void openFile() { ios_base::sync_with_stdio(false); cin.tie(NULL); #ifdef Tr___ freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); #endif } const int maxN = 1e5 + 5; const int maxM = 1e6 + 5; const llint INF = 1e18; llint findGap(int T, int N) { if (T == 1) { llint l = 0, r = INF; llint nl, nr; llint res = 0; FOR(i, 1, (N + 1) / 2) { MinMax(l + 1, r - 1, &nl, &nr); if (l != 0) { res = max(res, max(nl - l, r - nr)); } else if (N == 2) { res = nr - nl; break; } l = nl; r = nr; } return res; } else { llint l, r; MinMax(0, INF, &l, &r); if (N == 2) { return r - l; } llint lower = (r - l) / (N - 1); llint res = lower; llint nl, nr; do { llint x = 0; nl = nr = -1; while (nl == -1) { ++x; MinMax(l + 1, l + lower * x, &nl, &nr); } res = max(res, nl - l); l = nr; } while (l != r); return res; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...