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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long findGap(int T, int N) {
if (T == 1) {
vector<long long> A(N);
long long L = 0, R = 1000000000000000000;
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 {
long long L = 0, R = 1000000000000000000;
long long MN, MX;
MinMax(L, R, &MN, &MX);
L = MN, R = MX;
long long Size = (R - L + N - 2) / (N - 1);
MinMax(L, L + Size - 1, &MN, &MX);
long long Cur = MX;
long long ANS = 0;
for (long long i = 1; i < N - 1; i++) {
MinMax(L + Size * i, L + Size * (i + 1) - 1, &MN, &MX);
if (MN != -1) {
ANS = max(ANS, MN - Cur);
Cur = MX;
}
}
return ANS;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |