Question
Maximum Sum Subarray of Size K
You are given an array of KaTeX can only parse string typed expression integers. Your task is to find the maximum possible sum among all contiguous subarrays of size exactly KaTeX can only parse string typed expression.
Input
The first line contains two integers KaTeX can only parse string typed expression and KaTeX can only parse string typed expression — the size of the array and the size of the subarray.
The second line contains KaTeX can only parse string typed expression integers representing the array — KaTeX can only parse string typed expression.
The second line contains KaTeX can only parse string typed expression integers representing the array — KaTeX can only parse string typed expression.
Output
Print a single integer — the maximum sum of any contiguous subarray of size exactly KaTeX can only parse string typed expression.
Example
Input
5 3
2 1 5 1 3
Output
9
Explanation
Subarrays of size 3 are:
(2, 1, 5) → sum = 8
(1, 5, 1) → sum = 7
(5, 1, 3) → sum = 9
Maximum sum = 9
5 3
2 1 5 1 3
Output
9
Explanation
Subarrays of size 3 are:
(2, 1, 5) → sum = 8
(1, 5, 1) → sum = 7
(5, 1, 3) → sum = 9
Maximum sum = 9