Submission #347969

#TimeUsernameProblemLanguageResultExecution timeMemory
347969joylintpGap (APIO16_gap)C++17
12.89 / 100
67 ms1388 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); long long 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...