What is wrong in my code?

package arrays;

import java.util.Scanner;

public class painterpartition {

public static void main(String[] args) {
	Scanner scn = new Scanner(System.in);
	int n = scn.nextInt();
	int k = scn.nextInt();
	
	int [] board=new int[n];
	int lo=0;
	int hi=0;

	for (int i = 0; i < n; i++) {
		board[i]=scn.nextInt();
		hi += board[i];

	}
	int finalans=0;
	
	while(lo<=hi) {
		
		int mid=lo+hi/2;
		
		if (isitpossible(board,n,k,mid)) {
			finalans=mid;
			hi=mid-1;
		}else {
			lo=mid+1;
		}
	}
	System.out.println(finalans);

}
public static boolean isitpossible(int[] board,int n,int k,int mid) {
	int painters=1;
	int time=0;
	
	int i=0;
	while(i<n){
		if (time+board[i]<=mid) {
			time +=board[i];
			i++;
		}
		else {
			painters++;
			time=0;
			if (painters>k) {
				return false;
			}
		}
		
	}
	return true;
	
}

Hey @harsh.hj
Input format
First line contains K which is the number of painters. Second line contains N which indicates the number of boards. Third line contains N space separated integers representing the length of each board.
so,
int k = scn.nextInt(); // pehle aayega
int n = scn.nextInt();
and
int mid = (lo + hi) / 2; instead of int mid = lo + hi / 2;
correct code : https://ide.codingblocks.com/s/319371