#include "race.h"
#include <bits/stdc++.h>
using namespace std;
int besthub(int n, int len, int* a, long long b) {
vector<long long> pref(n);
for (int i = 0; i < n; i++) {
if (i == 0) {
pref[i] = a[i];
} else {
pref[i] = pref[i - 1] + a[i];
}
}
auto Can = [&](int l, int r) {
int mid = l + r >> 1;
long long ll = (long long) a[mid] * (mid - l + 1) - (pref[mid] - (l == 0 ? 0LL: pref[l - 1]));
long long rr = pref[r] - pref[mid] - (long long) a[mid] * (r - mid);
return ll + rr <= b;
};
int ans = 1;
for (int i = 0; i < n; i++) {
int bot = i, top = n - 1, mx = 0;
while (bot <= top) {
int mid = bot + top >> 1;
if (Can(i, mid)) {
mx = mid - i + 1;
bot = mid + 1;
} else {
top = mid - 1;
}
}
ans = max(ans, mx);
}
return ans;
}
Compilation message
ricehub.cpp:1:10: fatal error: race.h: No such file or directory
1 | #include "race.h"
| ^~~~~~~~
compilation terminated.