This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/* be name khoda */
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
#define forifrom(i, s, n) for (ll i = s; i < n; ++i)
#define fori(i, n) forifrom(i, 0, n)
#define F first
#define S second
// ------------------------------------------------------------------
const ll maxn = 100010;
const ll maxa = 1000000000000000000;
ll A[maxn];
long long findGap(int T, int N) {
if (T == 1) {
A[0] = -1;
A[N + 1] = maxa + 1;
for (ll i = 0, j = N + 1; j - i > 1; ++i, --j) {
MinMax(A[i] + 1, A[j] - 1, A + i + 1, A + j - 1);
}
ll ans = 0;
forifrom (i, 1, N) ans = max(ans, A[i + 1] - A[i]);
return ans;
} else {
ll lt, rt;
MinMax(0, maxa, <, &rt);
ll d = (rt - lt + N - 2) / (N - 1);
ll i = lt, j = lt, best = d;
while (j < rt) {
ll a, b; MinMax(j + 1, j + d, &a, &b);
if (a != -1) {
best = max(best, a - i);
i = j = b;
} else {
j += d;
}
}
return best;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |