#K36362. Maximum Sum Subarray of Fixed Length
Maximum Sum Subarray of Fixed Length
Maximum Sum Subarray of Fixed Length
Given an array of integers and an integer k, find the maximum sum of any continuous subarray of length k. In other words, for an array \(A = [a_0, a_1, \dots, a_{n-1}]\) and an integer \(k\), compute the maximum value of
[ S = \sum_{j=i}^{i+k-1} a_j, \quad 0 \leq i \leq n-k ]
If \(k\) is greater than the length of the array then output None.
inputFormat
The first line contains an integer n denoting the number of elements in the array. The second line contains n space-separated integers representing the array elements. The third line contains an integer k, the length of the subarray.
outputFormat
Output a single line containing the maximum sum of any continuous subarray of length k. If k is greater than the length of the array, output None.
## sample6
1 12 -5 -6 50 3
4
51