#K66267. Sliding Window Average Sales
Sliding Window Average Sales
Sliding Window Average Sales
You are given a sequence of daily sales figures and an integer n representing the size of a sliding window. Your task is to compute the average sales for each consecutive subsequence (window) of n days. Use the formula \(\frac{1}{n}\sum_{i=1}^{n} x_i\) to calculate the average for each window, and round the result to two decimal places.
If the sliding window size is zero, negative, or larger than the number of available sales figures, then no window can be formed and you should output nothing.
inputFormat
The input is given via standard input (stdin):
- The first line contains two integers k and n separated by a space, where k is the number of daily sales figures, and n is the size of the sliding window.
- The second line contains k space-separated numbers, each representing a daily sales figure. These numbers can be integers or floating point values.
If k is zero, the second line will be empty.
outputFormat
Output the average sales for each sliding window of n consecutive days. Each average must be rounded to two decimal places and printed on a single line, separated by a single space. If no valid window exists, output nothing.
## sample5 2
1 2 3 4 5
1.50 2.50 3.50 4.50