Monkey Vs Bamboo
Time Limit: 1 sec
The Problem
For a very long time, monkeys are trying to get on the top of the oily bamboo. They have been tired now. After this so long period they have become wiser too. They're succeeded only in group. They can get on the top anytime now but not in the old style. They get on each another's shoulder and make a monkey tower. Then one of them who can reach at the top enjoys the glory and shares his joy with all. Anyway, there is a saying,
"Success has no SHORTCUTS".
They face a problem here too. The monkey which stays at lower needs to be strong enough literally to lift the rests. Though they got little wiser but they are monkey after all. As a human child, you got to help them with your chunky brain.
* A monkey can lift 'k' monkeys if and only if the sum of all 'k' monkeys’ weights on his shoulder is less or equal to his own weight.
The Input
There are several test cases. For each test case, you'll be provided an integer N (0<N<31) and N integers on next line that stands for each monkey's weight Wi (0<Wi <30000) where i indicates ith monkey (1<=i<=N).
The Output
For each cases, output will be a single line printing "Case X: Monkeys got BAMBOO." if they can build a monkey tower in their determined sequence, otherwise print "Case X: BAMBOO got Monkeys.". Here X is test case starting from 1.
Sample Input
5
3 1 30 15 50
5
50 30 18 2 1
Sample Output
Case 1: Monkeys got BAMBOO.
Case 2: BAMBOO got Monkeys.
Online Practice Contest 1 [School & College Level]
Problem Setter: Saiful Islam Niloy