Best Window of Size K
Among all contiguous windows of exactly K elements, print the maximum window sum.
Input: the first line has N and K; the second line has N integers.
Output: the maximum sum over windows of size K.
Constraints:
- 1 ≤ K ≤ N ≤ 105
- −109 ≤ ai ≤ 109
Sample Tests
Input 1
6 3 2 1 5 1 3 2
Output 1
9
Input 2
2 2 -5 -2
Output 2
-7
Discussion (opens after you solve — no spoilers before)
No comments yet.