CBOJ Fall Contest Problem 2 - Raking Leaves


Submit solution

Points: 7 (partial)
Time limit: 0.5s
Java 1.0s
Python 1.0s
Memory limit: 128M

Authors:
Problem type

Bob is raking leaves for some money!

After surveying N houses on his street Bob has an estimation on the amount of money he'll be paid if he rakes a specific house. More specifically, raking the i-th house will earn him Ci dollars. As Bob is very lazy, he will only select exactly K consecutive houses to rake.

What is the maximum amount of money Bob can make after raking K consecutive houses?

Input Specification

The first line of the input will contain two integers N and K (1KN105), indicating the number of houses ligned up and the number of consecutive houses Bob will select.

The next line of the input will contain N integers ranging from 0 to 109 inclusive. The i-th integer indicates the amount of money Bob can earn from raking the i-th house.

Output Specification

Output an integer, representing the maximum number of cash Bob can earn.

Subtasks

Subtask 1 [40%]

1KN50

Subtask 2 [60%]

No additional constraints.

Sample Input

Copy
6 2
1 2 3 1 0 4

Sample Output

Copy
5

Sample Explanation

Bob can rake the second and third house to get 2+3=5 dollars. There are no better options that this.


Comments

There are no comments at the moment.