69. Maximum Sum Window
EasySliding Window
Print the maximum sum of any k consecutive elements.
Input format
Line 1: n k Line 2: n integers
Output format
The maximum window sum.
Example 1
Input
6 3 2 1 5 1 3 2
Output
9
Example 2
Input
4 4 1 2 3 4
Output
10
Constraints
1 ≤ k ≤ n ≤ 10⁵
Read input from standard input and print the answer to standard output. Your code is judged against 6 test cases, most of them hidden.
Loading the MyLoginn IDE…