#C14611. Moving Average Calculation

    ID: 44280 Type: Default 1000ms 256MiB

Moving Average Calculation

Moving Average Calculation

You are given a list of integers and a sliding window size. Your task is to compute the moving average for each contiguous subarray of the list having length equal to the window size. The moving average is defined as:

$$\text{avg}_i = \frac{\sum_{j=i}^{i+\text{window\_size}-1}\text{nums}[j]}{\text{window\_size}}$$

Each computed average must be rounded to two decimal places. If the list length is less than the window size, output an empty result.

Note: The input will be provided via standard input (stdin) and your program should print the output to standard output (stdout).

inputFormat

The input consists of three lines:

  1. The first line contains an integer n representing the number of elements in the list.
  2. The second line contains n space-separated integers.
  3. The third line contains an integer window_size which is the size of the sliding window.

outputFormat

Output a single line containing the moving averages for each valid window. Each average must be printed as a floating-point number rounded to two decimal places and separated by a space. If no window is valid, output an empty line.

## sample
5
1 2 3 4 5
3
2.00 3.00 4.00