Submission #47659

#TimeUsernameProblemLanguageResultExecution timeMemory
47659E869120Gap (APIO16_gap)C++14
50.22 / 100
235 ms2336 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[31], LL = t - s, V = 15; for (int i = 0; i <= V; i++) { long double E = 1.0L*LL*i / (1.0L*V); B[i] = (long long)(1.0L*E); } B[V] = LL; for (int i = 0; i < V; i++) saiki(s + B[i], s + 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...