Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Bear and Game

By aro001 · Limits 1s, 512 MB

“Your life is over, you haven’t noticed yet!!!” Masha shouted. “What are you doing??”

Bear was playing a computer game. There were N enemies and he had to kill them all. Each of the enemies had power P. He can attack them with attacking power A. When an enemy is attacked the power of the enemy becomes ((PA)+ 10^9)%10^9.

There are three types of attacks:

 Bear can attack an enemy without any weapon. Bear loses 1 HP and the power of this attack is 1.

 Bear can stab an enemy with a knife. Bear loses 1 HP and the power of this attack is 2.

 Bear can attack an enemy with an M416 rifle. Bear loses 1 HP and the power of this attack is 5.

Now he thinks that there is a lot of things to do in life. So he is no more interested to waste time playing the game. But he is curious whether he could win the game or not. Bear wins the game if all the enemies are dead and he has a non negative HP. He would be happy if he could win the game.As you are a great programmer, Bear asked you about the result of the game.

You will be given an integer T (1<=T<=100) the number of test cases. For each test case there are two integers N and H (1<=N<=10^5, 0<=H<=10^5) the number of enemies and the HP of Bear. Then follows N integers a1,a2,a3….an where ai is the current power of ith enemy.(1<=ai<=10^5).

For each test case you have to print a line with test case number and “ :-)” if Bear could win otherwise “ :-(“.

Sample

InputOutput
```2
3 10
10 2 3
3 2
10 2 3
```
```Case 1: :-)
Case 2: :-(
```

Statistics

73% Solution Ratio

Nazmul_HossinEarliest, 3w ago

Nazmul_HossinFastest, 0.0s

Nazmul_HossinLightest, 0 B

mdvirusShortest, 315B