#include <bits/stdc++.h>
#define ll long long
#define loop(i, a, b) for(ll i=a;i<b;++i)
#define pool(i, a, b) for(ll i=a-1;i>=b;--i)
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define pb(a) pop_back(a)
#define eb(...) emplace_back(__VA_ARGS__)
#define sc scanf
#define vc vector
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define llmax LLONG_MAX/2
#define llmin -LLONG_MAX/2
using namespace std;
#define par pair<ll, ll>
#define ld long double
#define mod 998244353
int besthub(int n, int L, int[] X, ll B){
vc<ll> x(n+1, 0);
loop(i, 0, n) x[i+1]=X[i];
vc<ll> pr=x;
loop(i, 1, n+1) pr[i]+=pr[i-1];
function<ll (ll, ll)> query=[&](ll l, ll r){
return pr[r] - pr[l-1];
};
function<ll (ll, ll)> cost=[&](ll l, ll r){
ll mid=(l+r)/2;
ll ret=0;
if(l<mid) ret+=(mid-l) * x[mid] - query(l, mid-1);
if(mid<r) ret+=query(mid+1, r) - (r-mid) * x[mid];
return ret;
};
ll r=1, ans=0;
loop(l, 1, n+1){
while(r+1<=n and cost(l, r+1)<=(ll)B) ++r;
ans=max(ans, r-l+1);
}
return (int)ans;
}
Compilation message
ricehub.cpp:23:33: error: expected ',' or '...' before 'X'
23 | int besthub(int n, int L, int[] X, ll B){
| ^
ricehub.cpp: In function 'int besthub(int, int, int*)':
ricehub.cpp:25:26: error: 'X' was not declared in this scope
25 | loop(i, 0, n) x[i+1]=X[i];
| ^
ricehub.cpp:44:44: error: 'B' was not declared in this scope
44 | while(r+1<=n and cost(l, r+1)<=(ll)B) ++r;
| ^