Geeting ! sign for two test cases

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

public static void main(String[] args) throws IOException {
	
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
	 long NumofPainters=Long.parseLong(br.readLine());
	 int NumofBoards=(int)Long.parseLong(br.readLine());
	long[] arr=new long[NumofBoards];
	StringTokenizer st=new StringTokenizer(br.readLine());
	for(int i=0;i<NumofBoards;i++) {
		arr[i]=Integer.parseInt(st.nextToken());
	}
	System.out.println(Mintime(arr, NumofPainters));
}
public static long Mintime(long[] arr,long numofPainters) {
	long high=getsum(arr);
	long low=getmax(arr);
	while(low<high) {
		long mid=low+(high-low)/2;
		long requiredpainters=calpainters(arr, mid);
		if(requiredpainters<=numofPainters) {
			high=mid-1;
		}else {
			low=mid+1;
		}
	}
	return low;
}
public static long getsum(long[] arr) {
	long sum=0;
	for(int i=0;i<arr.length;i++) {
		sum+=arr[i];
	}
	return sum;
}
public static long getmax(long[] arr) {
	long max=Integer.MIN_VALUE;
	for(int i=0;i<arr.length;i++) {
		if(arr[i]>max) {
			max=arr[i];
		}
	}
	return max;
}
public static long calpainters(long[] arr,long mid) {
	long total=0;
	long painters=1;
	for(int i=0;i<arr.length;i++) {
		total+=arr[i];
		if(total>mid) {
			painters++;
			total=arr[i];
		}
	}
	return painters;
}

}

All the test cases are passed except two which is showing a msg like
Test Case 1 !
Test Case 5!

please tell me how to resolve it.

@ubaidshaikh9999
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.*;

public class Main {

public static void main(String[] args) throws IOException {
Scanner scn=new Scanner(System.in);
int NumofPainters=scn.nextInt();
int NumofBoards=scn.nextInt();
long[] arr=new long[NumofBoards];

for(int i=0;i<NumofBoards;i++) {
	arr[i]=scn.nextInt();
}
System.out.println(Mintime(arr, NumofPainters));

}
public static long Mintime(long[] arr,long numofPainters) {
long high=getsum(arr);
long low=getmax(arr);
while(low<high) {
long mid=low+(high-low)/2;
long requiredpainters=calpainters(arr, mid);
if(requiredpainters<=numofPainters) {
high=mid;
}else {
low=mid+1;
}
}
return low;
}
public static long getsum(long[] arr) {
long sum=0;
for(int i=0;i<arr.length;i++) {
sum+=arr[i];
}
return sum;
}
public static long getmax(long[] arr) {
long max=Integer.MIN_VALUE;
for(int i=0;i<arr.length;i++) {
if(arr[i]>max) {
max=arr[i];
}
}
return max;
}
public static long calpainters(long[] arr,long mid) {
long total=0;
long painters=1;
for(int i=0;i<arr.length;i++) {
total+=arr[i];
if(total>mid) {
painters++;
total=arr[i];
}
}
return painters;
}
}

this code is working fine because in some test cases there is some extra space so your ParseLong() function will give exception.

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.