#C9674. Maximum Sum of Contiguous Subarray of Fixed Length

    ID: 53793 Type: Default 1000ms 256MiB

Maximum Sum of Contiguous Subarray of Fixed Length

Maximum Sum of Contiguous Subarray of Fixed Length

You are given an array of integers of size N and an integer L. The task is to find the maximum sum of any contiguous subarray of length L.

In mathematical terms, for an array \( a_1, a_2, \ldots, a_N \), you need to compute: \[ S = \max_{1 \leq j \leq N-L+1} \left\{ \sum_{i=j}^{j+L-1} a_i \right\} \]

You are required to read the input from stdin and output the result to stdout.

inputFormat

The first line of input contains two space-separated integers N and L, where N is the size of the array and L is the length of the contiguous subarray.

The second line contains N space-separated integers representing the elements of the array.

outputFormat

Output a single integer representing the maximum sum of any contiguous subarray of length L.

## sample
5 2
1 2 3 4 5
9