Logo
(追記) (追記ここまで)

32804번 - Taking Out the Trash 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
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
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /