Under construction

Still being built. Things may change

Osmos (Small)

Interview

Time limit5sMemory limit512 MB

Summary
Starting from size A, sort the other motes and absorb each smaller one, adding helper motes or deleting blockers for the fewest operations.
Level

Medium5 of 10

Topics
Greedy, Sorting
Solved
No attempts yet

Problem

Armin is playing Osmos, a physics puzzle game made by Hemisphere Games. He controls a mote, a small particle that moves around and absorbs motes smaller than itself.

When Armin's mote absorbs a smaller mote, it grows by the size of the mote it absorbed. Once it is bigger, it absorbs motes that were out of reach before. Suppose Armin's mote has size 10 and the other motes have sizes 9, 13 and 19. At the start only the mote of size 9 can be absorbed, and absorbing it brings Armin's mote to size 19. Next it absorbs the mote of size 13 and reaches size 32, and only then does it absorb the last mote.

A mote is absorbed only when it is strictly smaller than Armin's mote. A mote of the same size cannot be absorbed.

You are in charge of the program that lays out the motes. The layout it produced may leave Armin's mote unable to absorb everything. You may perform two kinds of operations, in any order and any number of times: add one mote whose size is a positive integer, or remove one mote that is already in the game. One add and one remove each count as one operation. Find the minimum number of operations that lets Armin's mote absorb every other mote.

For example, if Armin's mote has size 10 and the other motes have sizes 9, 20, 25 and 100, the layout cannot be cleared as it stands. Adding a mote of size 3 and removing the mote of size 100 clears it in two operations, and one operation is not enough.

Input

The first line contains the number of test cases TT. Each test case takes two lines. The first line has the size of Armin's mote AA and the number of other motes NN. The second line has the NN sizes of the other motes. Every size is an integer.

Limits

  • 1≤T≤1001 \le T \le 100
  • 1≤A≤1001 \le A \le 100
  • 1≤N≤101 \le N \le 10
  • every mote size is between 1 and 100

Output

For each test case, print one line of the form Case #x: y, where x is the test case number starting from 1 and y is the minimum number of operations that makes the game solvable.

Hint

Mote sizes in the input never go above 100, but Armin's mote grows past that limit while it absorbs.

A mote you add stays in the game, so it has to be absorbed as well.

Osmos was made by Hemisphere Games. This problem has no connection to Hemisphere Games.

Examples1

  1. Example 1

    Input
    4
    2 2
    2 1
    2 3
    1 1 6
    10 4
    25 20 9 100
    1 4
    1 1 1 1
    
    Expected output
    Case #1: 0
    Case #2: 1
    Case #3: 2
    Case #4: 4