bool verify(int r, int l, int x[], int b, int nr)
{
int st, dr, mij, total;
for(int i=0;i<r-nr+1;i++)
{
st=i;
dr=i+nr-1;
mij=(st+dr)/2;
total=0;
for(int j=st;j<=mij;j++)
total+=x[mij]-x[j];
for(int j=mij+1;j<=dr;j++)
total+=x[j]-x[mij];
if(total<=b)
return true;
}
return false;
}
int besthub(int r, int l, int x[], int b)
{
int st=1, dr=r+1, mij;
while(dr-st>1)
{
mij=(st+dr)/2;
if(verify(r,l,x,b,mij))
st=mij;
else
dr=mij;
}
return st;
}
Compilation message
/usr/bin/ld: /tmp/cc7cP6cb.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