#C4900. Maximum Sum of Contiguous Subarray with Fixed Length
Maximum Sum of Contiguous Subarray with Fixed Length
Maximum Sum of Contiguous Subarray with Fixed Length
You are given an array of integers and an integer \(K\). Your task is to find the maximum sum of any contiguous subarray of exactly \(K\) elements.
If the array has fewer than \(K\) elements, output None
.
The solution should be efficient with respect to time complexity. A typical approach is to use the sliding window technique.
inputFormat
The input is given via standard input (stdin). The first line contains two integers (N) and (K) separated by a space, where (N) is the number of elements in the array and (K) is the fixed length of the subarray. If (N > 0), the second line contains (N) space-separated integers representing the array elements.
outputFormat
Output the maximum sum of any contiguous subarray of length (K) to standard output (stdout). If the array contains fewer than (K) elements, output None
.## sample
6 3
2 1 5 1 3 2
9
</p>