Battery Pack Merging

View as PDF

Submit solution


Points: 100
Time limit: 1.0s
PyPy 3 2.0s
Python 3 2.0s
Memory limit: 256M

Problem type

Your device needs at least T total charge before it can turn on.

You have n battery packs, and the i-th pack provides c_i units of charge. Each pack can be used at most once, and you may merge any collection of packs together. It is allowed for the total charge to be more than T.

What is the minimum number of battery packs needed to reach at least T total charge? If even using every battery pack is not enough, output -1.

Input

The first line contains two integers n and T.

The second line contains n integers c_1, c_2, \ldots, c_n, where c_i is the charge of the i-th battery pack.

Output

Output a single integer: the minimum number of battery packs needed to reach at least T total charge, or -1 if it is impossible.

Constraints

  • 1 \le n \le 2 \times 10^5
  • 1 \le T \le 10^{14}
  • 1 \le c_i \le 10^9

Example 1

Input
5 12
3 8 4 5 2
Output
2
Explanation

Using the packs with charge 8 and 5 gives a total of 13, so two packs are enough.

Example 2

Input
4 20
6 4 5 3
Output
-1
Explanation

All four packs together only give 18 total charge.

Example 3

Input
2 10
9 9
Output
2
Explanation

One pack is not enough, but both packs together give 18 total charge.


Comments

There are no comments at the moment.