CSES - Ferris Wheel

Xem dạng PDF

Gửi bài giải

Điểm: 1,00 (OI)
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 512M
Input: stdin
Output: stdout

Nguồn bài:
https://cses.fi/problemset/task/1090
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

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?

Input

  • The 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,\ldots,p\_n~: the weight of each child.

Output

  • Print one integer: the minimum number of gondolas.

Constraints

  • ~1 \le n \le 2 \cdot 10^5~
  • ~1 \le x \le 10^9~
  • ~1 \le p\_i \le x~

Example Input

4 10
7 2 3 9

Example Output

3

Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.