FARIDA - Princess Farida


Once upon time there was a cute princess called Farida living in a castle with her father, mother and uncle. On the way to the castle there lived many monsters. Each one of them had some gold coins. Although they are monsters they will not hurt. Instead they will give you the gold coins, but if and only if you didn't take any coins from the monster directly before the current one. To marry princess Farida you have to pass all the monsters and collect as many coins as possible. Given the number of gold coins each monster has, calculate the maximum number of coins you can collect on your way to the castle.

Input

The first line of input contains the number of test cases. Each test case starts with a number N, the number of monsters, 0 <= N <= 10^4. The next line will have N numbers, number of coins each monster has, 0 <= The number of coins with each monster <= 10^9. Monsters described in the order they are encountered on the way to the castle.

Output

For each test case print “Case C: X” without quotes. C is the case number, starting with 1. X is the maximum number of coins you can collect.

Example

Input:
2
5
1 2 3 4 5
1
10

Output:
Case 1: 9
Case 2: 10

hide comments
sakshi: 2015-12-03 13:28:49

easy one:)

carofe82: 2015-10-16 18:22:23

AC at first shot. Easy DP problem. Very nice problem.

Last edit: 2015-10-24 08:00:10
bunnycoder: 2015-10-10 07:46:40

Try www.spoj.com/problems/BYTESM2 before doing this question.

senshiya: 2015-10-04 13:03:50

simple but mst for beginners :)

topke: 2015-09-28 02:12:41

Be careful i was using I64d format specifier for outputing long long and it gave me lots of wrong answers. Changed it to lld and it worked fine

gullu_mishra: 2015-09-17 10:57:34

m beginr of DP ..... took 2hrs to understand... njoyed the problm as a beginr of DP... :) gd prblm for basic of dp

Amit Doshi: 2015-09-17 08:05:13

For test case in which N=0, take a blank line as input, ie,
1 //Test Case No
0 //N
//Press enter here
Case 1: 0

Abishek: 2015-09-17 04:50:16

used top down approach and memoisation. learnt something new.:D!

dhoni_him17: 2015-08-25 22:01:50

array for bottom up : size 3 will do

dhoni_him17: 2015-08-25 22:00:03

4 WA coz of space before newline ;(


Added by:hossamyosef
Date:2013-05-13
Time limit:1.237s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:FCIS/ASU Local Contest 2013