1094 : Make Rounddog Very Happy

时间限制Time Limit 6 Sec 内存限制Memory Limit 128 MB 提交次数Submitted 69 Times 通过次数Solved 13 Times 标准评测Standard Judge

题目描述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

出题Author

ftiasch