The F1 Pace Delta

An F1 team is training an ML model to predict the performance for each lap. Your task is to develop a feature that informs the model about the comparison of each lap to the recent pace. So, you decide for each lap to compare its time to the average of the most recent laps before it; that way, the model can learn if the car is trending faster or slower.

The first line of the input contains two integers - n, the total number of laps recorded, and w, the window size of how many previous laps to average (1 ≤ w ≤ n).

The second line contains n space-separated floating-point lap times .

For each lap, look back at up to the previous w laps and take their average; if there are no earlier laps yet, treat that average as 0. After that, print the difference between the current lap and the earlier average.

Input

Output

5 3
90 88 92 91 89

90
-2
3
1
-1.333

4 2
1.0 1.2 1.1 0.9

1
0.2
0
-0.25

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue