Sphere Online Judge

SPOJ Problem Set (classical)

11372. Blueberries

Problem code: RPLB


Teresa picked up enough strawberries, now she wants to pick blueberries from the magical blueberry bush from Rainbowland.

 

Knowing her previous experience with the strawberries, Teresa wants to pick up the blueberries in a way that she may not exceed the limit proposed.

 

When picking the blueberries, she noticed that if she pick from the bush i, she couldn't pick the blueberries at the bush i+1 (some sort of magic in rainbowland).

 

Worried about this, Teresa wants to know the maximum blueberries she can pick, given the number of bushes and the number of blueberries in each bush.

 

INPUT:

Will contain an integer T, then, T cases will follow, each case starts with a number N and K, being N the number of bushes and K the number of blueberries Teresa will pick as maximum, the next line contains N integers, each one representing the blueberries there is on the i-th bush.

 

OUTPUT:

You will output for each test case the string: “Scenario #i: “ where i is the test case you are analyzing, then, an integer denoting the maximum number of blueberries you can grab.

 

INPUT

OUTPUT

2

5 100

50 10 20 30 40

 

5 87

21 45 30 12 14

Scenario #1: 90

Scenario #2: 65

 

Blank line between test cases for clarification and separation”

Output explanation (first scenario)

Teresa picks the 1st blueberry bush (50), she cannot pick the 2nd, she decides not to pick until the 5th one where she picks the “40” blueberry, she could pick the 3rd bush, but she would exceed the limit (100).

Output explanation (second scenario)

Teresa picks the 1st, the 3rd and the 5th bush, total of (21+30+14 = 65) blueberries

 

CONSTRAINTS:

1<=N<=1000; 1<=K<=1000


Added by:David Moran
Date:2012-04-12
Time limit:3s
Source limit:50000B
Memory limit:256MB
Cluster: Pyramid (Intel Pentium III 733 MHz)
Languages:All
Resource:Own Problem used for the RPL contest

hide comments
2013-04-29 13:00:11 Animesh Sinha
@David
If I pick up blueberries at 'i' and don't pick up at 'i+2', can I pick up at 'i+3' ?
2013-02-22 10:57:30 Alex Abbas
@problem setter: can you tell me whats wrong with my submission 8761885 and thanks.
2012-12-28 17:32:00 Paul Draper
@D White, this is not very clear from the problem description, but Teresa may pick either all of the berries or none of the berries on a bush.
2012-08-10 04:34:48 D White
In scenario #1, why not pick the 50, the 20, and then 30 of the 40 from bush 5?
2012-05-29 04:56:28 ~!(*(@*!@^&
classic problem.
2012-04-21 22:25:00 Suraj D
Nice Problem!!
2012-04-15 15:39:30 Francky
Nice problem, Not AC yet, but I search !
Edit : @problem setter : can you say what could be the problem with my last submission ? Thanks.

David Says: You should look from a distinct approach. ;)
Francky Says : Back to a new approach, and it's AC. ;-)


Last edit: 2012-04-18 10:03:27
2012-04-14 20:16:17 Senjougahara Hitagi
It is a kind of "guess the statement" game without a constraint on T...
SPOJ © 2013 Sphere Research Labs. All Rights Reserved.