#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
//#include "ricehub.h"
#include "grader.cpp"
using namespace std;
#define ll long long
const int N = 1e5 + 7;
ll a[N], pr[N], sf[N];
int n;
ll mx;
bool solve (int l, int r){
int mid = ((l + r) >> 1) + 1;
ll cost = (pr[mid] - pr[l] - (a[mid] - a[l]) * 1LL * (l - 1)) + (sf[mid] - sf[r] - (a[r] - a[mid]) * 1LL * (n - r));
return cost <= mx;
}
int besthub(int R, int L, int X[], long long B){
n = R; mx = B;
for (ll i = 0; i < n; i++){
a[i + 1] = X[i];
pr[i + 1] = pr[i] + i * (a[i + 1] - a[i]);
}
for (ll i = n; i >= 1; i--)
sf[i] = sf[i + 1] + (n - i) * (a[i + 1] - a[i]);
int l = 1, r = n + 1;
while (r - l > 1){
int mid = (l + r) >> 1;
bool ans = false;
for (int i = 1; i + mid - 1 <= n; i++)
ans |= solve(i, i + mid - 1);
if (ans)
l = mid;
else
r = mid;
}
return l;
}
Compilation message
/tmp/ccfgzcLn.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccltH6Vo.o:ricehub.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status