CSG-CPC
Online Judge

1094 : Make Rounddog Very Happy

         Time Limit: 6 Sec     Memory Limit: 128 MB     Submitted: 67     Solved: 11    

Description

The task is adapted from HDOJ 6701 - Make Rounddog Happy.

Bobo has a sequence of integers a1, a2, …, an and an integer m.

Let f(j) be the number of i where 1 ≤ i ≤ j and max {ai, …, aj} − (j − i + 1) ≥ m hold. Find the value of f(1), …, f(n).

Input

The input consists of several test cases terminated by end-of-file.

The first line of each test case contains two integers n and m, and the second line contains n integers a1, a2, …, an.

  • 1 ≤ n ≤ 106
  •  − n ≤ m ≤ n
  • 1 ≤ ai ≤ n
  • The sum of n does not exceed 5 × 106.

Output

For each test case, print n integers f(1), …, f(n).

Sample

3 0
1 3 2
3 1
1 3 2
5 2
1 2 3 4 5
1 2 3
0 2 2
0 0 1 2 3

Hint

Author

ftiasch