| Author: | Pavel Mesenev | Time limit: | 2 sec | |
| Input file: | Standard input | Memory limit: | 256 Mb | |
| Output file: | Standard output |
A stream of n integers a0, a1, …, an − 1 arrives one at a time, together with a fixed window size k (1 ≤ k ≤ n), known in advance. For every position i with i ≥ k − 1, report the sum of the last k values seen so far: ai − k + 1 + ai − k + 2 + … + ai.
The first line contains two integers n and k. The second line contains n space-separated integers a0… an − 1.
Print n − k + 1 lines: the sliding-window sum for i = k − 1,k,…,n − 1, in order.
1 ≤ k ≤ n ≤ 2 ⋅ 105
− 109 ≤ ai ≤ 109
Every printed sum fits into a signed 64-bit integer.
| No. | Standard input | Standard output |
|---|---|---|
| 1 |
|
|
| 2 |
|
|
| 3 |
|
|