407989: GYM102961 C Ferris Wheel
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
C. Ferris Wheeltime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output
There are $$$n$$$ children who want to go to a Ferris wheel, and your task is to find a gondola for each child.
Each gondola may have one or two children in it, and in addition, the total weight in a gondola may not exceed $$$x$$$. You know the weight of every child.
What is the minimum number of gondolas needed for the children?
InputThe first input line contains two integers $$$n$$$ and $$$x$$$: the number of children and the maximum allowed weight.
The next line contains $$$n$$$ integers $$$p_1,p_2,\dots,p_n$$$: the weight of each child.
Constraints:
- $$$1 \le n \le 2\cdot 10^5$$$
- $$$0 \le x \le 10^9$$$
- $$$1 \le p_i \le x$$$
Print one integer: the minimum number of gondolas.
ExampleInput4 10 7 2 3 9Output
3