Book Allocation Problem

Please check my code its giving correct answer in Eclipse IDE but giving wrong answers on CB IDE

import java.util.Scanner;

public class Main {

public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int t=sc.nextInt();
	
	while(t!=0) {
		int n=sc.nextInt(); //NO. of books
		int m=sc.nextInt(); //No. of students
		
		long[] pages=new long[n];
		for(int i=0;i< n;i ++) {
			pages[i] = sc.nextInt();
		}
		System.out.println(bookPages(pages, n, m));
		t--;
	}
	sc.close();
}


public static long bookPages(long [] pages, int n, int m) {
	long sum=0;
	for(int i=0;i<n; i++) {
		sum+=pages[i];
	}
	
	long si=pages[n-1];
	long ei =sum;
	long ans =Integer.MAX_VALUE;
	while(si<ei) {
		long mid=(si+ei)/2;
		
		if(isPossible(pages,n,m,mid)) {
			ans=Math.min(ans, mid);
			ei=mid-1;
		}else {
			si=mid+1;
		}
	}
	return ans;
}

public static boolean isPossible(long[] pages, int n, int m, long ans) {
	long students =1;
	long current_pages =0;
	
	for(int i=0;i<n;i++) {
		if(current_pages+pages[i]>ans) {
			current_pages =pages[i];
			students++;
			if(students>m) {
				return false;
			}
		}else {
			current_pages+=pages[i];
		}
	}
	return true;
}

}

@Ritik488
there is just slight mistake in your code
while(si<=ei){
this should be the codition other it will not check few cases.
}