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.


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.


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.


1 2 3 4 5

Case 1: 9
Case 2: 10

hide comments
sabkx: 2021-10-10 08:09:59

use long long instead of int

dhrn75: 2021-09-26 18:09:08

Wasted terrible time on this case -> n == 0
Do consider this while writing any solution

aparnaphoebe: 2021-08-30 21:49:57

Exactly same as : https://leetcode.com/problems/house-robber/

sal_vat_ion: 2021-07-12 20:05:27

stupid n == 0 case.

vrintle: 2021-06-23 18:21:47

WTF? what does the problem wants to say? am I that dumb that I can't even get it, let alone solvering :')
Don't be like me guysss!

Last edit: 2021-06-23 18:29:19
aggarwal1443: 2021-06-16 16:24:08

Come on guys u can do it just push your limit day by day :)

csd_123: 2021-06-16 06:32:25

my 50th

voldemort_11: 2021-06-12 22:58:46

Don't get too confused , it's easy :)

loser_404: 2021-06-09 10:20:46

I'm a loser indeed

Last edit: 2021-06-09 15:53:57
null12_21: 2021-05-27 20:09:59

just try and don't be a fag like me

Last edit: 2021-05-27 23:43:53

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