RPLB - Blueberries


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.

Example

Input:
2
5 100
50 10 20 30 40
5 87
21 45 30 12 14

Output:
Scenario #1: 90
Scenario #2: 65

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


hide comments
vl4deee11: 2024-03-12 04:44:05

ac in one go, use dp[1000][1001];

Francky: 2022-02-21 23:59:43

@nadstratosfer who asked, and maybe others : how did I manage a 0.03s using Py3 ?
YES, it's DP, it's unthinkable to do anything else.
But, ultra fast IO, and only bitwise operation for the DP process.
With the old days of pyramid cluster, I got the lonely 0.00s using C. The cube cluster ruined my rank. I still have the lonely Py3 AC sub. With that hint, you should try !

avsd_47: 2020-10-01 17:39:09

basically the story is when "farida" got a "knapsack".....(check out those two if u haven't done)

lakshya1st: 2020-09-02 20:54:53

AC in one go!! easy-peasy :)

havokkk: 2020-07-31 18:46:26

sounds like 0/1 knapsack with extra steps

amansahu112: 2020-05-02 12:17:12

easy one

kabbo25: 2020-04-25 00:13:24

try house roober problem,same concept

aryan29: 2020-04-01 21:14:06

Too easy it is

scolar_fuad: 2019-10-26 11:41:20

modified 0/1 knapsake
easy dp not recommand for beginner

scolar_fuad: 2019-09-18 17:45:32

Nice variation of 0/1 knapsake easy dp ...

happy coding


Added by:david_8k
Date:2012-04-12
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:Own Problem used for the RPL contest