Slide Count
문제
In your programming class, you are given an assignment to analyze an integer array using a sliding window algorithm. Specifically, given integers and some constant , the sliding window algorithm maintains start and end indices and such that
- initially ;
- as long as :
- if , then increment ;
- else if , then increment ;
- else increment .
During the execution of this algorithm, each distinct pair of indices defines a window. An element belongs to the window defined by if . Notice that if , the window is empty.
Consider the first sample input below. The windows appearing during the execution of the algorithm are defined by , , , , , , , , , and .
For each element , determine how many different windows it belongs to during the execution of the sliding window algorithm.
입력
The first line of input contains two integers (), which is the number of elements, and (), which is the sliding window constant.
The next line contains integers ().
출력
For each element, in order, display the number of different windows it belongs to during the execution of the algorithm.
예제
예제 1
5 3 1 1 1 2 2
3 3 4 2 1
예제 2
5 10 1 2 3 4 5
4 4 4 5 2