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 <bits/stdc++.h>
using namespace std;
const long long inff = 1e18;
long long findGap(int t, int n) {
if (t == 1) {
long long l = 0, r = inff;
vector<long long> a(n);
for (int i = 0; i < (n + 1) / 2; i++) {
long long mn, mx;
MinMax(l, r, &mn, &mx);
a[i] = mn;
a[n - 1 - i] = mx;
l = mn + 1;
r = mx - 1;
}
long long ans = 0;
for (int i = 0; i < n - 1; i++) ans = max(ans, a[i + 1] - a[i]);
return ans;
} else if (t == 2) {
long long l = 0, r = inff, mn, mx;
MinMax(l, r, &mn, &mx);
long long ans = (mx - mn) / (n - 1), lst = mn;
l = mn + 1;
r = mx;
while (l < r) {
MinMax(l, l + ans - 1, &mn, &mx);
l += ans;
ans = max(ans, mn - lst);
if (mx != -1) lst = mx;
}
ans = max(ans, r - lst);
return ans;
}
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:42:1: warning: control reaches end of non-void function [-Wreturn-type]
42 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |