3 test cases going wrong

https://ide.codingblocks.com/s/162500 Here is my solution .its showing wrong answer for 3 test cases but i am unable to figure out which test case may go wrong

your approach was totally correst
to see the changes in the code
pls see the —> symbol

import java.util.*;
public class Main {
public static int givep(int []arr,int value)
{
int total = 0, c = 1; ---->
for (int i = 0; i < arr.length; i++) {
total += arr[i]; —>
if (total > value) { —>
// for next count
total = arr[i]; —>
c++;
}
}
return c;
}

public static int pp(int []arr,int p)
{
	int max=0,sum=0,lo,hi,mid,ans=0;
	for(int i=0;i<arr.length;i++)
	{
		sum+=arr[i];
		if(max<arr[i])
		max=arr[i];

	}
	lo=max;
	hi=sum;
	while(lo<hi)
	{                                         --->
		 mid=(lo+hi)/2;
		int count=givep(arr,mid);
		if(count<=p)
		{	ans=mid;
			hi=mid;
		}
		else
		{
			lo=mid+1;
		}
	}
	return ans;
	

}
public static void main(String args[]) {
	int p,n;
	Scanner sc=new Scanner(System.in);
	p=sc.nextInt();
	n=sc.nextInt();
	int arr[]=new int[n];
	for(int i=0;i<n;i++)
	arr[i]=sc.nextInt();
	System.out.println(pp(arr,p));
}

}

Sir now i got the correct output but I could not figure out what was wrong in my code and how your changes helped

bro just make a dry run for simple test case.

and the appraoch which i used is very simple
actually i dont remember right now what was the mistake

shayad mistake givenp method me tha

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.