시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB148706055.556%

문제

You are in charge of feeding the seals in the Welsh Mountain Zoo. This involves purchasing buckets of fish and allocating them to volunteers to trek into the enclosure and distribute fairly to the blubbery residents.

The buckets of fish are already set out. Each volunteer can be assigned to carry either one or two of these buckets, as long as the combined weight of the buckets is small enough.

How many volunteers will you need to distribute all of the fish in one trip?

입력

  • The first line contains the number of buckets to be delivered, n (1 ≤ n ≤ 105), and the integer carrying capacity of a volunteer, c (1 ≤ c ≤ 109).
  • The second line contains the integer weights of each of the n buckets, w1 . . . wn (1 ≤ w ≤ c).

출력

Output the minimum number of volunteers required to deliver all of the buckets of fish.

예제 입력 1

4 100
44 35 66 67

예제 출력 1

3

예제 입력 2

1 10
7

예제 출력 2

1

예제 입력 3

3 12
10 5 6

예제 출력 3

2

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > The UK & Ireland Programming Contest > UKIEPC 2019 F번

  • 문제를 만든 사람: Ian Pratt-Hartmann