제출 #793223

#제출 시각아이디문제언어결과실행 시간메모리
793223kingfran1907Gap (APIO16_gap)C++14
59.04 / 100
41 ms1072 KiB
#include "gap.h" #include <algorithm> typedef long long llint; const llint maxn = 2e18; using namespace std; long long findGap(int t, int n) { llint sol = 0; if (t == 1) { llint a, b; MinMax(0, maxn, &a, &b); while (n >= 2) { if (n == 2) sol = max(sol, b - a); n -= 2; llint ta, tb; MinMax(a + 1, b - 1, &ta, &tb); sol = max(sol, max(ta - a, b - tb)); a = ta, b = tb; } } else { llint a, b; MinMax(0, maxn, &a, &b); llint delta = b - a; llint mini = delta / n; llint las = a; for (llint t = a + 1; t < b; t += mini) { llint ta, tb; if (t + mini >= b) { if (t >= b - 1) break; MinMax(t, b - 1, &ta, &tb); } else MinMax(t, t + mini - 1, &ta, &tb); if (ta > -1) { sol = max(sol, ta - las); las = tb; } } sol = max(sol, b - las); } return sol; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...