#C7447. Minimum Boxes Required

    ID: 51319 Type: Default 1000ms 256MiB

Minimum Boxes Required

Minimum Boxes Required

You are given (n) items with weights and a box weight limit (w). Each box can hold at most two items, and the total weight of items in a box cannot exceed (w). Your task is to determine the minimum number of boxes required to pack all the items.

For example, if there are 5 items each weighing 5 and the box limit is 10, then three boxes are needed: two boxes can each hold two items (5+5 (\leq) 10) and the last box holds the remaining one item.

inputFormat

The input is given via standard input (stdin) and consists of two lines.

The first line contains two integers (n) and (w) separated by a space, where (n) is the number of items and (w) is the maximum weight a box can hold.

The second line contains (n) space-separated integers representing the weights of the items.

outputFormat

Output a single integer to standard output (stdout) representing the minimum number of boxes required to pack all the items.## sample

5 10
5 5 5 5 5
3

</p>