CBOJ Fall Contest Problem 2 - Raking Leaves
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 \(C_i\) 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\) \((1 \le K \le N \le 10^5)\), 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 \(10^9\) 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%]
\(1 \le K \le N \le 50\)
Subtask 2 [60%]
No additional constraints.
Sample Input
6 2
1 2 3 1 0 4
Sample Output
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