6745.Elevator Rides

Time Limit: 1s Memory Limit: 512MB

There are $n$ people who want to get to the top of a building which has only one elevator. You know the weight of each person and the maximum allowed weight in the elevator. What is the minimum number of elevator rides?

Input Format(From the terminal/stdin)

The first input line has two integers $n$ and $x$ : the number of people and the maximum allowed weight in the elevator.

The second line has $n$ integers $w_1,w_2,\dots,w_n$ : the weight of each person.

  • $1 \le n \le 20$
  • $1 \le x \le 10^9$
  • $1 \le w_i \le x$

Output Format(To the terminal/stdout)

Print one integer: the minimum number of rides.

Sample Input

Copy
4 10
4 8 6 1
 ·  \n
 · · · \n

Sample Output

Copy
2
 \n
Source: CSES, Dynamic Programming, 1653

Submit

请先 登录

© 2025 FAQs