#K94737. Minimum Number of Delivery Trucks
Minimum Number of Delivery Trucks
Minimum Number of Delivery Trucks
In this problem, you are tasked with determining the minimum number of trucks needed to deliver a set of parcels. Each truck has a weight capacity (C) and each parcel has a specified weight. A truck can deliver multiple parcels if the sum of their weights does not exceed its capacity, that is, if for a set of parcels (S) we have (\sum_{i \in S} p_i \le C). For each test case, you are given the number of parcels and the capacity of a truck, followed by the weights of the parcels. Your program should assign parcels to trucks using a greedy strategy so that the total number of trucks used is minimized. The answer for each test case should be printed in the format: Case #x: y
, where x
is the test case number (starting from 1) and y
is the number of trucks required.
inputFormat
The input is read from standard input (stdin). The first line contains an integer (T) representing the number of test cases. For each test case, the first line contains two integers (N) and (C) where (N) is the number of parcels and (C) is the weight capacity of each truck. The following line contains (N) integers representing the weights of the parcels.
outputFormat
For each test case, output a line in the format Case #x: y
on standard output (stdout), where x
is the test case number (starting from 1) and y
is the minimum number of trucks required to deliver all the parcels.## sample
2
4 10
2 3 5 8
3 15
5 9 12
Case #1: 2
Case #2: 2
</p>