Problem Description
Given an array, a nonempty subarray is defined as a continuous piece of that array. More specifically, is a subarray of if is the result of deleting zero or more elements from the front of , and zero or more elements from the end.
Given an array of length and an integer , what is the largest sum of a subarray of , if the subarray has to be of size ?
Input Format
The first line of the input will be two integers, and . The next line of the input will consist of integers, representing .
Output Format
Output a single integer, the maximum sum of a subarray of that is length .
Constraints
Sample Input 1
5 3
1 -2 3 -4 5
Sample Output 1
4
Sample Input 2
8 3
-512 750 27 -532 -940 781 -449 278
Sample Output 2
610
Comments