#K35812. Minimum Shelf Operations

    ID: 25615 Type: Default 1000ms 256MiB

Minimum Shelf Operations

Minimum Shelf Operations

You are given a set of books with given weights and a weight limit W for each operation. In one operation, you can move a collection of books from one shelf to another, as long as the total weight of the books you select does not exceed W (i.e. \( \sum weights \leq W \)). Your task is to calculate the minimum number of operations required to move all the books.

More formally, for each test case you are given two numbers \(N\) and \(W\) where \(N\) is the number of books and \(W\) is the maximum total weight you can move in one operation. The following line contains \(N\) integers denoting the weights of the books.

You can choose the books in any order in each operation. It is guaranteed that the books can always be moved by repeatedly selecting some books such that their total weight does not exceed \(W\).

inputFormat

The input is read from standard input (stdin) and has the following format:

  • The first line contains a single integer \(T\) representing the number of test cases.
  • For each test case, the first line contains two integers \(N\) and \(W\), where \(N\) is the number of books and \(W\) is the maximum weight limit per operation.
  • The second line of each test case contains \(N\) space-separated integers denoting the weights of the books. If \(N = 0\), this line may be empty.

outputFormat

For each test case, print one integer on a new line representing the minimum number of operations required to move all the books.

## sample
2
5 10
3 3 3 3 3
4 12
6 4 8 10
2

3

</p>