For this Question: A conveyor belt has parcels that must be shipped from one point to another within D days.

The i-th parcel on the conveyor belt has a weight of weights[i].  Each day, we load the ship with parcels on the conveyor belt (in the order given). We may not load more weight than the maximum weight capacity of the ship.

Return the least weight capacity of the ship that will result in all the parcels on the conveyor belt being shipped within D days.

Note:- the cargo must be shipped in the order givenThe input line contains T, denoting the number of testcases. Each testcase contains two lines. First line N ,contains size of the conveyor belt and D days separated by space. Second line contains weights of parcels.

Constraints:
1 <= T <= 100
1 <= D <= N <= 5*10^4
1 <= weights[i] <= 500
Sum if N over all test cases is <= 1000000For each testcase you need to print the least weight capacity of the ship that will result in all the parcels on the conveyor belt being shipped within D days.Sample Input:
2
10 5
1 2 3 4 5 6 7 8 9 10
6 3
3 2 2 4 1 4

Sample Output:
15
6

Explanation:
Testcase 1: 
A ship capacity of 15 is the minimum to ship all the parcels in 5 days like this:
1st day: 1, 2, 3, 4, 5
2nd day: 6, 7
3rd day: 8
4th day: 9
5th day: 10

Note that the cargo must be shipped in the order given, so using a ship of capacity 14 and splitting the parcels into parts like (2, 3, 4, 5), (1, 6, 7), (8), (9), (10) is not allowed., I have written this Solution Code: import java.util.*;
import java.io.*;
import java.lang.*;

class Main
{
    public static void main(String args[])throws IOException
    {
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
        int t = Integer.parseInt(read.readLine());


        while(t-- > 0)
        {

            String str[] = read.readLine().trim().split(" ");
            int N = Integer.parseInt(str[0]);
            int D = Integer.parseInt(str[1]);

            int arr[] = new int[N];
            str = read.readLine().trim().split(" ");
            for(int i = 0; i < N; i++)
                arr[i] = Integer.parseInt(str[i]);

            int res = shipWithinDays(arr, D);
            //print(res);
            System.out.println(res);

        }
    }

    static void print(int list[])
    {
        for(int i = 0; i < list.length; i++)
            System.out.print(list[i] + " ");

    }

    public static int shipWithinDays(int[] weights, int D) {

        // set lower/upper bound for binary search
        int low = 0, high = 0;

        for(int weight: weights) {
            low = Math.max(low, weight);
            high += weight;
        }

        while(low < high) {
            int mid = low + (high - low)/2;

            if(calDays(mid, weights) > D) {
                low = mid + 1;
            } else {
                high = mid;
            }
        }

        return low;
    }
    public static int calDays(int w, int[] weights) {
        int days = 0;
        int accuSum = 0;
        for(int i=0;i<weights.length;i++) {
            if(accuSum + weights[i] <= w) {
                accuSum += weights[i];
            } else {
                accuSum = weights[i];
                days++;
            }
        }

        if(accuSum>0) {
            days++;
        }

        return days;
    }

}, In this Programming Language: Java, Now tell me if this Code is compilable or not?