Canadian Computing Competition: 2007 Stage 1, Senior #5
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
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 Specification
Input consists of a series of test cases. The first line of input is n k w
. First is the integer
Output Specification
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
Output for Sample Input
39
Comments
Are you able to knock down less pins than the width of the bowling ball?
if, say, the sequence of pins is 1 2 3 4 5 6 7 8 9, and the width of the ball is 3, if I were to knock down 5 6 7, would I be able to then knock down 4 8 9, or would the space restrict me from doing so?
The space would restrict you from doing so.