#P12802. [AMPPZ 2019] Assimilation
[AMPPZ 2019] Assimilation
Description
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 planets in the system, inhabited by people, respectively. Aliens start with assimilation ships and are allowed to make any of the following moves:
-
An invasion requires landing on a planet with some part of the fleet. The number of landing ships must be greater or equal to the population of the planet. After the invasion, these ships disappear, the planet is conquered and now has inhabitants.
-
A mobilization creates, from a conquered planet, a number of new ships equal to the population of the planet. Every planet can be mobilized at most once.
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.
Input Format
The first line of input contains the number of test cases . The test cases follow, each one in the following format:
- The first line of every test case contains two integers and — the number of planets, and the size of Aliens’ initial fleet.
- The second line contains integers — the populations of the respective planets.
The sum of values over all test cases does not exceed .
Output Format
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 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
京公网安备 11011102002149号