#P1404. Maximum Subarray Average with Minimum Length Constraint
Maximum Subarray Average with Minimum Length Constraint
Maximum Subarray Average with Minimum Length Constraint
Given a sequence of n integers, find a contiguous subarray with length at least m such that its average is maximized. The average of a subarray from index l to r is defined as:
$$\frac{\sum_{i=l}^{r} a_i}{r-l+1}$$
You are to output the maximum average value computed to exactly six decimal places.
inputFormat
The first line contains two integers n and m (1 ≤ m ≤ n). The second line contains n space-separated integers representing the sequence.
outputFormat
Output the maximum average value among all contiguous subarrays with length at least m, formatted to exactly six decimal places.
sample
5 3
1 2 3 4 5
4.000000