| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 3 초 | 2048 MB | 28 | 18 | 17 | 65.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.
4 1000 100 900 200 900
3
4 10 1 2 3 4
2
ICPC > Regionals > North America > Pacific Northwest Regional > 2024 ICPC Pacific Northwest Regional > Division 2 L번