CSES Problemset/Sorting and Searching
Ferris Wheel
#1090Ask AI
Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.
Open Claude DesktopThere are 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 . You know the weight of every child.
What is the minimum number of gondolas needed for the children?
Input
The first input line contains two integers and : the number of children and the maximum allowed weight.
The next line contains integers : the weight of each child.
Output
Print one integer: the minimum number of gondolas.
Constraints
Sample Test Cases (1)
Example 1ID: sample-1
Input
4 10 7 2 3 9
Expected Output
3
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|1 line, 0 charsTest Bench
Input (stdin)
4 10 7 2 3 9
Expected Output
3