#P1419. Maximum Average Subarray
Maximum Average Subarray
Maximum Average Subarray
You are given an integer sequence \(a\) of length \(n\), where \(a_i\) denotes the value of the \(i^{th}\) element. A segment is defined as a contiguous subsequence with length in the interval \([S, T]\). The average value of a segment is defined as the sum of the segment's values divided by its length, that is, using LaTeX notation:
\[ \text{Average} = \frac{\text{Sum of segment values}}{\text{Segment length}} \]
Your task is to find the segment with the maximum average among all segments whose lengths are between \(S\) and \(T\) (inclusive).
inputFormat
The input consists of two lines:
- The first line contains three integers \(n\), \(S\), and \(T\) where \(n\) is the length of the sequence and \(S\) and \(T\) define the inclusive range of segment lengths.
- The second line contains \(n\) space-separated integers representing the sequence \(a\).
outputFormat
Output a single number: the maximum average value among all valid segments. Print the answer rounded to 6 decimal places.
sample
5 2 3
1 12 -3 5 7
6.500000