#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
bool chmax(ll &a, const ll &b) {
return a < b ? a = b, true : false;
}
long long findGap(int T, int n) {
ll lmn = -1, lmx = 1e18 + 1;
ll ans = 0;
for(int i = 0; i < (n + 1) / 2; i++) {
ll cmn, cmx;
MinMax(lmn + 1, lmx - 1, &cmn, &cmx);
if(i > 0) {
chmax(ans, cmn - lmn);
chmax(ans, lmx - cmx);
}
if(i + 1 == (n + 1) / 2) {
chmax(ans, cmx - cmn);
}
lmn = cmn, lmx = cmx;
}
return ans;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |