Osmos (Large)
InterviewTime limit5sMemory limit512 MB
Starting from size A, absorb the sorted motes in order and use the fewest added or removed motes to clear each blocker.
Problem
Armin plays a game about motes. A mote is a small particle that absorbs other motes, or is absorbed by them.
Armin controls one mote. His mote absorbs another mote only if the other mote is strictly smaller. A mote of exactly the same size cannot be absorbed. Absorbing a mote adds that mote's size to Armin's mote, so his mote grows and may then absorb motes it could not touch before.
For example, suppose Armin's mote has size and the other motes have sizes , and . At the start his mote can absorb only the mote of size , which brings it to size . Then it absorbs the mote of size and reaches size , and only then can it absorb the last mote.
You prepare the motes Armin plays against. The size of Armin's mote and the sizes of the other motes are already fixed, and that set may leave no way for his mote to absorb everything. You may repair it with two operations, used in any order and any number of times: add a new mote of any positive integer size, or remove one of the existing motes.
Report the minimum number of operations that makes it possible for Armin's mote to absorb every other mote.
For example, if Armin's mote has size and the other motes are , , and , the game is not solvable as it stands. Adding a mote of size and removing the mote of size solves it in two operations, so the answer is .
Input
The first line has the number of games . Each game takes two lines. The first line has the size of Armin's mote and the number of other motes . The second line has the sizes of the other motes, separated by spaces. Every size is an integer.
- every other mote size is between and
Output
For each game print one line in the form Case #x: y, where is the game number starting at and is the minimum number of operations that solves that game.
Notes
The sizes given in the input are at most , but Armin's mote can grow past that bound while it absorbs. A mote you add has no upper bound either, it only has to be a positive integer.