#K16096. Minimum Trips for Package Delivery

    ID: 24502 Type: Default 1000ms 256MiB

Minimum Trips for Package Delivery

Minimum Trips for Package Delivery

Madison needs to deliver several packages and can only carry a limited weight W per trip. Given a list of package weights, your task is to compute the minimum number of trips required to deliver all the packages. In each trip, Madison can choose any subset of the remaining packages as long as their total weight does not exceed W. Solve the problem using a greedy strategy by attempting to carry the heaviest packages first.

Note: The optimal solution is to minimize the number of trips and each package can be delivered in one of the trips. The weight constraint for each trip is given by $W$.

inputFormat

The first line contains an integer T representing the number of test cases. Each test case is described in two lines:

  • The first line contains two space-separated integers N and W, where N is the number of packages and W is the maximum allowable weight per trip.
  • The second line contains N space-separated integers, each representing the weight of a package.

For each test case, you must output the minimum number of trips required on a new line.

outputFormat

For each test case, output a single integer on a new line indicating the minimum number of trips required to deliver all the packages.

## sample
2
4 10
2 3 5 7
4 10
1 2 3 8
2

2

</p>