#C9309. Max Sum of k Consecutive Subarrays

    ID: 53388 Type: Default 1000ms 256MiB

Max Sum of k Consecutive Subarrays

Max Sum of k Consecutive Subarrays

You are given an array of n integers. Your task is to find the maximum sum among the first k consecutive subarrays, each of which has a length of l. Formally, for an array a and integers n, l, and k, consider the subarrays:

\(a[i], a[i+1], \dots, a[i+l-1]\) for \(0 \le i \le k-1\).

You need to compute the sum of each subarray and output the maximum among these sums.

Note: It is guaranteed that \(l \le n\) and \(k+l-1 \le n\) so that each subarray is well-defined.

inputFormat

The first line of input contains three space-separated integers \(n\), \(l\), and \(k\), where \(n\) is the number of elements in the array, \(l\) is the length of each subarray, and \(k\) is the number of consecutive subarrays to consider.

The second line contains \(n\) space-separated integers representing the elements of the array.

Input is read from standard input (stdin).

outputFormat

Output a single integer: the maximum sum among the first \(k\) consecutive subarrays of length \(l\) from the given array.

The result should be written to standard output (stdout).

## sample
7 3 3
1 2 3 4 5 6 7
12