#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
ll a[100201];
ll l[100201], r[100201];
pll b[100201];
const ll inf = 1'000'000'000'000'000'000;
ll findGap(ll T, ll n) {
ll mn, mx, ret = 0;
MinMax(0, inf, &mn, &mx);
a[1] = mn, a[n] = mx;
ll gap = (mx - mn) / n;
for (ll i = a[1], cnt = 1; cnt <= n; i += gap, cnt++) {
l[cnt] = i, r[cnt] = i + gap;
if (cnt == n) r[cnt] = a[n];
}
bool full = true;
for (int i = 1; i <= n; i++) {
MinMax(l[i], r[i], &mn, &mx);
b[i] = {mn, mx};
if (mn == -1) full = false;
ret = max(ret, mx - mn);
}
if (full) {
for (int i = 2; i <= n; i++) {
ret = max(ret, b[i].first - b[i - 1].first);
}
}
else {
ll bef = -1;
for (int i = 1; i <= n; i++) {
if (b[i].first == -1) continue;
MinMax(bef, b[i].first, &mn, &mx);
ret = max(ret, mx - mn);
bef = b[i].second;
}
}
return ret;
}
Compilation message
/usr/bin/ld: /tmp/ccjHwG7A.o: in function `main':
grader.cpp:(.text.startup+0x1b7): undefined reference to `findGap(int, int)'
collect2: error: ld returned 1 exit status