#K14611. Maximum Average Speed
Maximum Average Speed
Maximum Average Speed
Given a list of speeds of N cars and an integer K, find the maximum average speed among all contiguous subarrays of length K. In other words, for any segment of K consecutive cars, calculate the average speed; the task is to determine the maximum of these averages. The answer must be printed with 6 decimal places.
The formula for the average speed of a segment is given by:
\( \text{Average} = \frac{\sum_{i=1}^{K} \text{speed}_i}{K} \)
where the summation is over K consecutive cars.
inputFormat
The first line of input contains two integers N and K separated by a space, representing the number of cars and the length of the segment respectively.
The second line contains N space-separated integers, where the i-th integer represents the speed of the i-th car.
outputFormat
Output the maximum average speed of any contiguous subarray of length K. The output should be a floating point number rounded to 6 decimal places.
## sample7 3
10 5 2 7 8 7 4
7.333333