#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
long long pf[maxn], ki, ka, mid, idxtengah, cost, res, ans;
long long besthub(long long R, long long L, long long X[], long long B)
{
for(int i=0; i<R; i++) {
pf[i]=X[i]+(i?pf[i-1]:0);
ki=0, ka=i;
while(ki<=ka) {
mid=(ki+ka)/2, idxtengah=(mid+i)/2;
cost=idxtengah*X[idxtengah]-(idxtengah?pf[idxtengah-1]:0);
cost+=pf[mid]-(idxtengah?pf[idxtengah-1]:0)-((mid-idxtengah)*X[idxtengah]);
if(cost<=B) res=mid, ka=mid-1;
else ki=mid+1;
}
ans=max(ans, i-res+1);
}
return ans;
}
Compilation message
/usr/bin/ld: /tmp/ccSJJR0v.o: in function `main':
grader.cpp:(.text.startup+0xae): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status