#K4511. Minimum Pallets
Minimum Pallets
Minimum Pallets
You are given t test cases. In each test case, you are given the number of items n and the maximum allowed weight m for each pallet. The next line contains n integers representing the weights of the items.
Your task is to determine the minimum number of pallets required to store all items such that the total weight of items in any single pallet does not exceed m. Items may be rearranged arbitrarily.
The constraint for each pallet can be expressed as:
$$\sum_{i\in S}w_i \le m,$$
where S is the set of items loaded on one pallet and wi is the weight of item i.
inputFormat
The input is read from standard input (stdin). The first line contains an integer t, the number of test cases. Each test case consists of two lines:
- The first line contains two space-separated integers n and m, where n is the number of items and m is the maximum weight that each pallet can support.
- The second line contains n space-separated integers, representing the weights of the items.
outputFormat
For each test case, output a single line containing the minimum number of pallets required such that the sum of item weights in each pallet does not exceed m.
## sample1
3 10
5 5 5
2
</p>