시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 512 MB | 211 | 75 | 64 | 38.788% |
An enlightened race of aliens plans to assimilate a star system, to help its inhabitants achieve perfection. They may resist, but – as you are all well aware – resistance is futile.
There are n planets in the system, inhabited by a1, a2, . . . , an people, respectively. Aliens start with 𝑘 assimilation ships and are allowed to make any of the following moves:
For Aliens, invasions are easy and natural, but mobilizations turn out to be a bit tricky. Help them conquer all the planets in the system with minimal possible number of mobilizations.
The first line of input contains the number of test cases z (1 ≤ z ≤ 30). The test cases follow, each one in the following format:
The first line of every test case contains two integers n and k (1 ≤ n ≤ 200 000; 1 ≤ k ≤ 109) – the number of planets, and the size of Aliens’ initial fleet. The second line contains n integers a1, . . . , an (1 ≤ ai ≤ 109) – the populations of the respective planets.
The sum of n values over all test cases does not exceed 500 000.
For every test case, output a single integer: the minimal number of mobilizations required to conquer all the planets. If such conquest is impossible, output −1 instead.
4 3 15 6 5 26 3 15 6 5 27 2 1000000000 500123123 497000000 7 2 6 2 4 1 9 3 12
2 -1 0 4