Bookallocation (getting error do tell me what is wrong in it)

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
long t=sc.nextLong();

	for(int i =0;i<t;i++) {
	long n = sc.nextLong();
	 long k =sc.nextLong();
	 
	 long book[]=new long[10000];
	for(int j=0;j<n;j++)
	{
		book[i]=sc.nextLong();
	}
	long result= binarySearch(book,n,k);
	System.out.println();
	}
	
}

public static long binarySearch(long books[], long n, long k) {
	long ans = 0, s = 0, e = 0;
	long sum = 0;
	for (int i = 0; i < n; i++) {
		sum += books[i];
		s = Math.max(s, books[i]);

	}
	e = sum;
	while (s <= e) {
		long mid = (s + e) / 2;
		if (isValid(books, n, k, mid)) {
			ans = mid;
			e = mid - 1;
		} else {
			s = mid + 1;
		}
	}
	return ans;

}

public static boolean isValid(long books[], long n, long k, long ans) {
	long students = 1;
	long current_page = 0;
	for (int i = 0; i < n; i++) {
		if(books[i]>ans) {
			return false;
		}
		if (current_page + books[i] > ans) {
			current_page = books[i];
			students++;
			if (students > n) {
				return false;
			}
		} else {
			current_page += books[i];

		}
	}
	return true;

}

}

import java.util.*;
public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
		int t=sc.nextInt();
		
		for(int i =0;i<t;i++) {
		int n = sc.nextInt();
		int k =sc.nextInt();
		 //make your array of length n
		long[] books=new long[n];
		for(int j=0;j<n;j++)
		{
			books[j]=sc.nextLong();//it should be books[j] and not books[i]
		}
        long result= binarySearch(books,n,k);
        System.out.println(result);
		}
	}

	public static long binarySearch(long books[], int n, int k) {
		long ans = 0, s = 0, e = 0;
		long sum = 0;
		for (int i = 0; i < n; i++) {
			sum += books[i];
			//s = Math.max(s, books[i]);

		}
		e = sum;
		while (s <= e) {
			long mid = (s + e) / 2;
			if (isValid(books, n, k, mid)) {
				ans = mid;
				e = mid - 1;
			} else {
				s = mid + 1;
			}
		}
		return ans;
	}

	public static boolean isValid(long books[], int n, int k, long ans) {
		int students = 1;
		long current_page = 0;
		for (int i = 0; i < books.length; i++) {
            if (books[i] > ans) {

				return false;
			}
			if (current_page + books[i] > ans) {
				current_page = books[i];
				students++;
				if (students > k) {//here students should be greater than k
					return false;
				}
			} else {
				current_page += books[i];

			}
		}
		return true;

    }
}