#P10483. 小猫爬山
小猫爬山
Problem Description
Freda and rainbow raise kittens. One day, the kittens are going to climb a mountain. After going through many hardships, they finally reach the top, but they are so tired that they do not want to walk down anymore.
Freda and rainbow have to pay to let them take a cable car down the mountain. Each cable car has a maximum load capacity of , and the weights of the kittens are . Of course, the total weight of kittens in any cable car cannot exceed . For each cable car they rent, Freda and rainbow have to pay 1 dollar, so they want to know the minimum number of dollars needed to transport all kittens down the mountain.
Input Format
The first line contains two integers and , separated by a space.
The next lines each contain one integer. The integer on line is the weight of the -th kitten, .
Output Format
Output one integer, the minimum number of dollars needed, i.e. the minimum number of cable cars.
5 1996
1
2
1994
12
29
2
Hint
Translated by ChatGPT 5