#K8376. Maximum Average Subarray

    ID: 36269 Type: Default 1000ms 256MiB

Maximum Average Subarray

Maximum Average Subarray

You are given an array of integers and an integer ( k ). Your task is to find the contiguous subarray of length ( k ) that has the maximum average, and print its average value as a floating-point number.

The problem can be solved efficiently using a sliding window technique. Make sure to output the result with at least one digit after the decimal point (for example, output 5.0 instead of 5).

inputFormat

The first line contains two integers ( n ) and ( k ), where ( n ) is the number of elements in the array and ( k ) is the length of the subarray. The second line contains ( n ) space-separated integers representing the array elements.

Example input:
6 4
1 12 -5 -6 50 3

outputFormat

Output a single floating-point number representing the maximum average of any contiguous subarray of length ( k ). Ensure the output retains at least one digit after the decimal point.## sample

6 4
1 12 -5 -6 50 3
12.75