#C13946. Moving Average Calculation

    ID: 43540 Type: Default 1000ms 256MiB

Moving Average Calculation

Moving Average Calculation

Given an array of integers and a window size n, compute the moving average for every contiguous subarray of length n. The moving average for a subarray \(a_i, a_{i+1}, \dots, a_{i+n-1}\) is defined as \(\frac{1}{n}\sum_{j=0}^{n-1}a_{i+j}\). If the window size is greater than the number of elements in the array, then no moving averages can be computed and the output should be empty.

For example, if the input array is [1, 2, 3, 4, 5] and n is 3, the output should be [2.0, 3.0, 4.0].

inputFormat

The input is given in two lines:

  1. The first line contains two integers m and n separated by a space, where m is the number of integers in the array and n is the window size.
  2. The second line contains m space-separated integers representing the array elements. If m is 0, the second line will be empty.

outputFormat

Output a single line with the moving averages for every contiguous subarray of size n, separated by a space. Each average should be printed as a floating-point number. If no moving average exists, output nothing.

## sample
5 3
1 2 3 4 5
2.0 3.0 4.0