I am unable to detect to detect my mistake So plz tell my about the correction

#include
using namespace std;
bool isvalid(int arr[],int no_of_student,int no_of_books,int ans)
{
int std=1,current_pages=0;
for(int i=0;i<no_of_books;i++)
{

    if(current_pages>ans)
    {
        std++;
        current_pages=arr[i];
    }
    else
    {
        current_pages=current_pages+arr[i];
    }
    if(std>no_of_student)
    return false;
}
return true;

}
int main()
{
int no_of_books,no_of_student,sum=0;
cin>>no_of_books;
int arr[no_of_books];
for(int i=0;i<no_of_books;i++)
{
cin>>arr[i];
sum=sum+arr[i];
}
cin>>no_of_student;
int start =0,end=sum,final_ans,mid=0;
while(start<=end)
{
mid=(start+end)/2;
if(isvalid(arr,no_of_student,no_of_books,mid))
{
end=mid-1;
final_ans=mid;
}
else start=mid+1;

 }
 cout<<final_ans;

}

#include
using namespace std;
#define ll long long int
bool isValidConfig(ll books[], ll bookno, ll students, ll mid)
{
int student = 1;
ll currpages =0;
for(int i=0; i<bookno; ++i)
{
if(currpages+books[i]>mid)
{
student++;
}
else
{
currpages+=books[i];
}
if(student >students)
{
return false;
}
}
return true;
}
ll binarysearchonbooks(ll books[], ll bookno, ll students)
{
ll totalpages=0;
ll s=0;
ll e=0;
for(int i=0; i<bookno;i++)
{
totalpages += books[i];
}
s = books[bookno-1];
e = totalpages;
ll finalans=0;
while(s<=e)
{
ll mid = (s+e)/2;
if(isValidConfig(books, bookno, students, mid))
{
e=mid-1;
finalans = mid;
}
else
{
s = mid+1;
}
}
return finalans;
}
int main()
{
ll n; //no of books
cin>>n;
ll m; //no of students
cin>>m;
ll books[n];
for(int i=0; i<n; ++i)
{
cin>>books[i];
}
ll ans = binarysearchonbooks(books,n, m );
cout<<ans;
}

this is the correct code

hey @Lovishbansal if your doubt is solved, please mark it as resolved

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.