#C2654. Sliding Window Sum

    ID: 45994 Type: Default 1000ms 256MiB

Sliding Window Sum

Sliding Window Sum

You are given a list of integers and an integer k. Your task is to compute the sum of every contiguous subarray (or "sliding window") of length k in the list.

More formally, given an array nums of length n and an integer k, for each i from 0 to n-k the sum of the window is:

\( S_i = \sum_{j=i}^{i+k-1} nums[j] \)

If k is 0, or if k > n, or if the list is empty, then the answer should be an empty list.

The input is read from the standard input (stdin) and the result should be printed to the standard output (stdout) as a sequence of integers separated by spaces. In the case there is no valid sliding window, print an empty line.

inputFormat

The first line contains two integers n and k, where n is the number of elements in the list and k is the window size.

The second line contains n space-separated integers representing the list nums. If n is 0, the second line may be absent or empty.

outputFormat

Output the sliding window sums in one line separated by a single space. If no sliding window exists, output an empty line.

## sample
8 3
1 3 -1 -3 5 3 6 7
3 -1 1 5 14 16