제출 #347968

#제출 시각아이디문제언어결과실행 시간메모리
347968joylintpGap (APIO16_gap)C++17
0 / 100
77 ms1304 KiB
#include "gap.h" #include<bits/stdc++.h> using namespace std; long long dfs(long long l, long long r) { if (r - l <= 1) return r - l; if (r - l == 2) { long long tl, tr; MinMax(l, l + 1, &tl, &tr); if (tr == l + 1) return 1; else return 2; } long long m = (l + r) / 2, ll, lr, rl, rr; MinMax(l + 1, m, &ll, &lr), MinMax(m + 1, r - 1, &rl, &rr); int ret; if (ll == -1 && rr == -1) ret = r - l; else if (ll == -1) ret = max({rl - l, dfs(rl, rr), r - rr}); else if (rr == -1) ret = max({ll - l, dfs(ll, lr), r - lr}); else ret = max({ll - l, dfs(ll, lr), rl - lr, dfs(rl, rr), r - rr}); return ret; } long long findGap(int T, int N) { long long l, r; MinMax(0, 1000000000000000000, &l, &r); return dfs(l, r); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...