#K39877. Minimum Albums Required

    ID: 26518 Type: Default 1000ms 256MiB

Minimum Albums Required

Minimum Albums Required

You are given an integer MM representing the number of stamps that Hanako received and an integer ZZ representing the capacity of each album. In addition, a list of MM positive integers is provided, where each integer denotes the size of a stamp. Your task is to determine the minimum number of albums needed to store all the stamps. Each album can hold stamps with a total combined size of at most ZZ. This problem can be viewed as a variant of the bin packing problem and can be solved using a greedy strategy.

inputFormat

The input is given via standard input. The first line contains two integers, MM and ZZ, where MM (0M1050 \leq M \leq 10^5) is the number of stamps and ZZ (1Z1091 \leq Z \leq 10^9) is the maximum capacity of each album. The second line contains MM integers separated by spaces, representing the sizes of the stamps. If MM is 0, the second line will be empty.

outputFormat

Output a single integer representing the minimum number of albums required to store all the stamps. The result should be printed to standard output.## sample

5 10
2 5 4 7 1
2

</p>