Slide Count

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

In your programming class, you are given an assignment to analyze an integer array using a sliding window algorithm.  Specifically, given NN integers w_1,,w_Nw\_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 w_s++w_e+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 w_iw\_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 w_iw\_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 (1N100,0001 \leq N \leq 100\\,000), which is the number of elements, and CC (1C1,000,0001 \leq C \leq 1\\,000\\,000), which is the sliding window constant. 

The next line contains NN integers w_1,,w_Nw\_1, \ldots, w\_N (0w_iC0 \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.