PivotOJ

Slide Count

시간 제한: 1000ms메모리 제한: 1024MB출처: ICPC Rocky Mountain Regional 2021BOJ 24759

문제

In your programming class, you are given an assignment to analyze an integer array using a sliding window algorithm.  Specifically, given NN integers w1,,wNw_1, \ldots, w_N and some constant CC, the sliding window algorithm maintains start and end indices ss and ee such that

  • initially s=e=1s = e = 1;
  • as long as sNs \leq N:
    • if e+1>Ne+1 > N, then increment ss;
    • else if ws++we+1>Cw_s + \cdots + w_{e+1} > C, then increment ss;
    • else increment ee.

During the execution of this algorithm, each distinct pair of indices (s,e)(s,e) defines a window.  An element wiw_i belongs to the window defined by (s,e)(s,e) if sies \leq i \leq e.  Notice that if s>es > e, the window is empty.

Consider the first sample input below.  The windows appearing during the execution of the algorithm are defined by (1,1)(1,1), (1,2)(1,2), (1,3)(1,3), (2,3)(2,3), (3,3)(3,3), (3,4)(3,4), (4,4)(4,4), (5,4)(5,4), (5,5)(5,5), and (6,5)(6,5).

For each element wiw_i, determine how many different windows it belongs to during the execution of the sliding window algorithm.

입력

The first line of input contains two integers NN (1N1000001 \leq N \leq 100\,000), which is the number of elements, and CC (1C10000001 \leq C \leq 1\,000\,000), which is the sliding window constant. 

The next line contains NN integers w1,,wNw_1, \ldots, w_N (0wiC0 \leq w_i \leq C).

출력

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
코드를 제출하려면 로그인하세요.