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 <bits/stdc++.h>
#include "gap.h"
using namespace std;
using ll = long long;
#define all(x) begin(x), end(x)
const ll MAX_A = 1e18;
ll findGap(int T, int N) {
ll mini = -1, maxi = MAX_A + 1;
int q = (N + 1) / 2;
vector<ll> a(N);
int i = 0, j = N - 1;
while (i <= j) {
MinMax(mini + 1, maxi - 1, &mini, &maxi);
assert(mini != -1), assert(maxi != -1);
a[i++] = mini, a[j--] = maxi;
}
ll maxGap = 0LL;
for (int i = 1; i < N; i++) {
maxGap = max(maxGap, a[i] - a[i - 1]);
}
return maxGap;
}
Compilation message (stderr)
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:14:9: warning: unused variable 'q' [-Wunused-variable]
14 | int q = (N + 1) / 2;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |