시간 제한메모리 제한제출정답맞힌 사람정답 비율
3 초 2048 MB28181765.385%

문제

Peter has way too much trash and he needs to take it all out.

Specifically, there are $n$ bags of trash each with a specific weight. Peter can hold either one or two bags of trash per trip, and he can carry a maximum total of $m$ milligrams of trash in a single trip. What is the minimum number of trips Peter needs to take to take out all the trash?

입력

The input starts with two integers $n$ $(1 \le n \le 5 \cdot 10^5)$ and $m$ $(1 \le m \le 10^9)$, the number of bags of trash and the maximum weight of trash Peter can carry.

The next line contains $n$ integers, $w_i$ $(1 \le w_i \le m)$, the weight of each bag of trash in milligrams.

출력

Output the minimum number of trips Peter needs to make to take out all the trash.

예제 입력 1

4 1000
100 900 200 900

예제 출력 1

3

예제 입력 2

4 10
1 2 3 4

예제 출력 2

2

출처

ICPC > Regionals > North America > Pacific Northwest Regional > 2024 ICPC Pacific Northwest Regional > Division 2 L번

  • 문제를 만든 사람: Jonathan Shen