#P10450. Maximum Average Subarray (USACO 2003 Mar. Green)
Maximum Average Subarray (USACO 2003 Mar. Green)
Maximum Average Subarray (USACO 2003 Mar. Green)
Given a sequence A of n non-negative integers and an integer L, find a contiguous subarray whose length is at least L and whose average is maximized. The maximum average should be output with six decimal places.
This problem is originally from USACO 2003 March (Green).
inputFormat
The first line contains two integers, n and L, where n is the length of the sequence and L is the minimum length of the subarray.
The second line contains n non-negative integers representing the sequence A, separated by spaces.
outputFormat
Output a single line with the maximum average of any contiguous subarray of length at least L, formatted to six decimal places.
sample
3 1
1 2 3
3.000000