Book Allocation Problem Please help

#include
#include<bits/stdc++.h>
using namespace std;

#define ll long long int

bool isValidConfig(ll arr[],ll n,ll m,ll ans)
{
int students=1;
ll currentpages=0;
for(int i=0;i<n;i++)
{
if(currentpages+arr[i]>ans)
{
currentpages=arr[i];
students++;
}

	if(students>ans)
	{
		return false;
	}
	else
	{
		currentpages+=arr[i];
	}
}
return true;

}

ll binarysearchbooks(ll arr[],ll n,ll m)
{
ll totalpages=0;
ll s=0;
ll e=0;
for(int i=0;i<n;i++)
{
totalpages+=arr[i];
s=max(s,arr[i]);
}

e=totalpages;

int finalans=s;

while(s<=e)
{
	ll mid=(s+e)/2;

	if(isValidConfig(arr,n,m,mid))
	{
		finalans=mid;
		e=mid-1;
	}
	else
	{
		s=mid+1;
	}
	
}

return finalans;

}

int main() {

int t;
cin>>t;

while(t--)
{
	ll n,m;

	cin>>n>>m;
    ll arr[100005];

	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}

	int ans=binarysearchbooks(arr,n,m);

	cout<<ans;
}
return 0;

}

There are a few mistakes at diff places,
declare the array of size n
in the isValidConfig function if( student > m ) has to be done and not ans
add a new line character after every test case
Updated code:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.