제출 #47653

#제출 시각아이디문제언어결과실행 시간메모리
47653E869120Gap (APIO16_gap)C++14
47.47 / 100
137 ms2308 KiB
#include "gap.h" #include <algorithm> #include <iostream> using namespace std; long long a[100009]; int res = 0; void saiki(long long L, long long R) { if (L >= R) return; long long s, t; MinMax(L, R - 1, &s, &t); if (s == -1) return; if (s == t) { res++; a[res] = s; return; } t++; long long B[5]; for (int i = 0; i <= 4; i++) B[i] = (s*(4LL - i) + t*i) / 4LL; for (int i = 0; i < 4; i++) saiki(B[i], B[i + 1]); } long long findGap(int T, int N) { if (T == 1) { long long L = 0, R = 1000000000000000000LL, s, t, cnt = 0; while (cnt < (N + 1) / 2) { MinMax(L, R, &s, &t); L = s; R = t; if (L != -1) { a[cnt + 1] = L; a[N - cnt] = R; } cnt++; L++; R--; } long long maxn = 0; for (int i = 1; i <= N - 1; i++) maxn = max(maxn, a[i + 1] - a[i]); return maxn; } if (T == 2) { saiki(0LL, 1000000000000000001LL); long long maxn = 0; for (int i = 1; i <= N - 1; i++) maxn = max(maxn, a[i + 1] - a[i]); return maxn; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...