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>
const long long iii = 1E18;
inline long long ceil(long long int a, long long int b) {
return a / b + (a % b != 0);
}
void MyMinMax(long long x, long long y, long long& min, long long& max) {
long long* min_place_holder = new long long;
long long* max_place_holder = new long long;
MinMax(x, y, min_place_holder, max_place_holder);
min = *min_place_holder;
max = *max_place_holder;
}
long long findGap(int T, int n) {
if (T == 1) {
std::vector <long long> a(n);
MyMinMax(0, iii, a[0], a[n - 1]);
for (int l = 1, r = n - 2; l <= r; l += 1, r -= 1) {
MyMinMax(a[l - 1] + 1, a[r + 1] - 1, a[l], a[r]);
}
long long int ans = 0;
for (int i = 0; i + 1 < n; i += 1)
ans = std::max(ans, a[i + 1] - a[i]);
return ans;
}
if (T == 2) {
long long min, max;
MyMinMax(0, iii, min, max);
long long siz = ceil(max - min, n - 1);
long long xaxa = -1;
long long bong = 0;
while (min <= max) {
long long yeunhau, coiaochonhau;
MyMinMax(min, min + siz, yeunhau, coiaochonhau);
if (yeunhau != -1) {
if (xaxa != -1) {
bong = std::max(bong, yeunhau - xaxa);
}
xaxa = yeunhau;
}
min += siz + 1;
}
return bong;
}
assert(0);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |