#K84327. Minimum Boxes for Product Packing
Minimum Boxes for Product Packing
Minimum Boxes for Product Packing
You are given several test cases. In each test case, there are (N) products with given weights and you have boxes that can hold at most (W) total weight. Your task is to determine the minimum number of boxes required to pack all the products such that the sum of the weights in each box does not exceed (W). You can arrange the products in any order. This is a variation of the bin packing problem which can be efficiently solved using a greedy strategy.
inputFormat
The first line of input contains an integer (T) indicating the number of test cases. For each test case, the first line contains two integers (N) and (W) where (N) is the number of products and (W) is the maximum weight capacity of each box. The second line contains (N) space-separated integers representing the weights of the products.
outputFormat
For each test case, output a single integer on a new line representing the minimum number of boxes required to pack all the products.## sample
1
3 10
4 8 3
2