This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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; }
res++; a[res] = s;
s++; t++;
long long B[31], LL = t - s, V = 8;
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |