#P7795. Maximum Average Subsequence

    ID: 20981 Type: Default 1000ms 256MiB

Maximum Average Subsequence

Maximum Average Subsequence

Given an array of n integers \(a = [a_1, a_2, \ldots, a_n]\), find a contiguous subsequence with length at least \(k\) that has the maximum average value. The average of a subsequence of length \(L\) is defined as:

$$ \frac{\sum_{i=1}^{L} a_i}{L} $$

Your task is to compute this maximum average and output it rounded to 6 decimal places.

inputFormat

The first line contains two integers \(n\) and \(k\) (where \(1 \le k \le n\)). The second line contains \(n\) space-separated integers, representing the elements of the array \(a\).

outputFormat

Output a single line with the maximum average value of any contiguous subsequence of length at least \(k\), rounded to 6 decimal places.

sample

5 3
1 2 3 4 5
4.000000