#K90527. Minimum Containers

    ID: 37772 Type: Default 1000ms 256MiB

Minimum Containers

Minimum Containers

You are given n cookies, each with a specified weight, and an unlimited number of containers. Each container can hold at most two cookies, provided that the total weight does not exceed \(W\) (the maximum weight capacity of a container). Note that if a cookie weighs more than \(W\), it still must be placed in its own container.

Your task is to determine the minimum number of containers required to pack all the cookies.

Constraints:

  • \(1 \leq n \leq 10^5\)
  • \(1 \leq W \leq 10^9\)
  • The weight of each cookie is a positive integer.

inputFormat

The first line contains two integers n and \(W\), separated by a space.

The second line contains n integers representing the weights of the cookies.

outputFormat

Print a single integer: the minimum number of containers required to pack all the cookies.

## sample
5 10
2 3 5 6 3
3

</p>