What is wrong with this code

include
using namespace std;
bool ispossible(int arr[],int n,int m,int curr_min)
{
int student_used=1;
int pages_reading=0;
for(int i=0;i<n;i++)
{
if((pages_reading +arr[i])>curr_min)
{
student_used++;
pages_reading=arr[i];
if(student_used>m)
{
return false;
}
}
else{
pages_reading+=arr[i];
}
}
return true;
}
int main() {
int t;
cin>>t;
int n,m;
cin>>n>>m;
int arr[1000];
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
int sum=0;
if(n<m)
{
return -1;
}
for(int i=0;i<n;i++)
{
sum+=arr[i];
}
int s=arr[n-1];
int e=sum;
int ans=INT_MAX;
while(s<=e)
{
int mid=(s+e)/2;
if(ispossible(arr,n,m,mid))
{
ans=min(ans,mid);
e=mid-1;
}
else
{
s=mid+1;
}
}
cout<<ans<<endl;
}

hello @Kunalgoyal
pls save ur code here -> https://ide.codingblocks.com/
and share the link with me

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.