2007 Canadian Computing Competition, Stage 1

Problem S5: Bowling for Numbers

At the Canadian Carnival Competition (CCC), a popular game is Bowling for Numbers. A large number of bowling pins are lined up in a row. Each bowling pin has a number printed on it, which is the score obtained from knocking over that pin. The player is given a number of bowling balls; each bowling ball is wide enough to knock over a few consecutive and adjacent pins.

For example, one possible sequence of pins is: 2 8 5 1 9 6 9 3 2

If Alice was given two balls, each able to knock over three adjacent pins, the maximum score Alice could achieve would be 39, the sum of two throws: 2 + 8 + 5 = 15, and 9 + 6 + 9 = 24.

Bob has a strategy where he picks the shot that gives him the most score, then repeatedly picks the shot that gives him the most score from the remaining pins. This strategy doesn’t always yield the maximum score, but it is close. On the test data, such a strategy would get a score of 20%.

Input

Input consists of a series of test cases. The first line of input is t, 1 ≤ t ≤ 10, indicating the number of test cases in the file. The first line of each test case contains three integers n k w. First is the integer n, 1 ≤ n ≤ 30000, indicating the number of bowling pins. The second integer, k, 1 ≤ k ≤ 500, giving the number of bowling balls available to each player. The third and final integer is w, 1 ≤ wn, the width of the bowling ball (the number of adjacent pins it can knock over). The next n lines of each test case each contain a single non-negative integer less than 10000, giving the score of the pins, in order. 20% of the test data will have size n ≤ 50.

Output

For each test case, output the maximum achievable score by the player. This score is guaranteed to be less than one billion.

Sample Input

1
9 2 3
2
8
5
1
9
6
9
3
2

Sample Output

39

All Submissions
Best Solutions


Point Value: 10 (partial)
Time Limit: 5.00s
Memory Limit: 256M
Added: Sep 30, 2008

Problem Types: [Show]

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

Can a ball ever knock over less than w adjacent pins? E.g. Hit only the right-most one?

You could, but I do not think that would very helpful in solving this problem.