BURGLARY - Boat Burglary

Rachid lives on a boat, and owns only a few items, n to be precise. He takes big care of his items, and measured the weight of each of them with high precision. Item i weights Wi micrograms. One night a thief visits his boat and steels some items. Rachid notices that the next morning, because the boat is lighter, and he could measure from the water level that this difference is D micrograms. He would like to know how many items are missing, just by examining these weights, and asks you for help.


The first line of the input consists of the number of test cases, T. T test cases follow. Each case consists of two lines, the first one containing two integers N and D, separated by a space. Then second line contains n integers, representing the weights of all items, separated by space.

The input satisfies the following limits.



For each test case output one line containing "Case #x: y", where x is the case number (starting from 1). If the number of missing items could be determined, then y is this number. If there are several answers to the problem y is the string "AMBIGIOUS" and if there is no answer y is the string "IMPOSSIBLE" (quotes added for clarity and are not part of the output).


5 10
2 3 6 9 5
5 20
1 4 2 3 15
5 20
1 4 5 15 27
5 16
1 2 4 8 32

Case #1: 3
Case #2: 3

hide comments
Christoph Dürr: 2016-10-07 16:56:37

Sorry for that, it should be fixed now.

:D: 2016-10-07 16:38:16

There's still something's wrong. The run froze on test case no 1.

Vikas Kumar: 2016-10-07 07:39:18

Last edit: 2016-10-07 07:47:36
:D: 2016-10-07 00:30:39

Submitting solutions to this problem is disabled. Please fix or hide the problem for now.

Added by:xtof
Time limit:1s-4s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 GOSU