What is the error`

#include<bits/stdc++.h>
using namespace std;
bool isPossible(int arr[], int n, int m, int curr_min)
{
int studentsRequired = 1;
int curr_sum = 0;

for (int i = 0; i < n; i++) 
{ 
     
    if (arr[i] > curr_min) 
        return false; 

     
    if (curr_sum + arr[i] > curr_min) 
    { 
        
        studentsRequired++; 

         
        curr_sum = arr[i]; 

         
        if (studentsRequired > m) 
            return false; 
    } 

    
    else
        curr_sum += arr[i]; 
} 
return true; 

}

int findPages(int arr[], int n, int m)
{
int sum = 0;

if (n < m) 
    return -1; 


for (int i = 0; i < n; i++) 
    sum += arr[i]; 


int start = arr[n-1], end = sum; 
int result = INT_MAX; 

 
while (start <= end) 
{ 
     
    int mid = (start + end) / 2; 
    if (isPossible(arr, n, m, mid)) 
    { 
        
        result = min(result, mid); 


        
        end = mid - 1; 
    } 

    else

        start = mid + 1; 
} 

 
return result; 

}

int main()
{

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

cout<< findPages(arr, n, m)<<endl; 
return 0; 

}

hey, can u please paste ur code onto the coding blocks ide and paste the link here, it is hard to debug this unindented code
nonetheless, posting a solution here

hey, if ur facing an error while submitting that is because of the input format, the first number in input has to be for the test cases,
secondly, u can put a check for zero students.
the logic u are using is correct