## Unbalanced

View as PDF

Points: 7
Time limit: 2.0s
Memory limit: 128M

Author:
Problem type

The unbalance of an array is the maximum value of the array minus the minimum. Given an array of length , can you find the unbalance of every subarray of length ?

A subarray of an array is defined as a set of consecutive elements in

#### Input Specification

The first line contains two integers: and .

The second line contains integers, the elements of .

#### Output Specification

integers, the -th of which is the unbalance of the subarray from the -th index to the -th index.

#### Sample Input

5 3
2 6 4 4 1

#### Sample Output

4 2 3

#### Sample Explanation

The three subarrays of length are: , , and .

The first one has a maximum of and a minimum of , so its unbalance is The second one has an unbalance of And the third has an unbalance of