Submission #47650

#TimeUsernameProblemLanguageResultExecution timeMemory
47650E869120Gap (APIO16_gap)C++14
30 / 100
2066 ms2324 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) { long long s, t; if (L >= R) { cout << "!" << endl; } MinMax(L, R - 1, &s, &t); if (s == -1) return; if (s == t) { res++; a[res] = s; return; } t++; long long T = 10; if (t - s <= T) { for (int i = s; i < t; i++) { saiki(i, i + 1); } } else if (t - s <= 100000000000LL) { for (int i = 0; i < T; i++) { long long G1 = 1LL * (t - s)*i / T; G1 += s; long long G2 = 1LL * (t - s)*(i + 1) / T; G2 += s; saiki(G1, G2); } } else { long long Y = (t - s) / T; Y++; for (int i = 0; i < T; i++) { long long G1 = 1LL * i*Y; G1 += s; long long G2 = 1LL * (i + 1)*Y; G2 += s; if (G1 >= G2) continue; saiki(G1, G2); } } } 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...