Antenna Analysis

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

문제

Åke has heard that there may be some suspicious 5G radiation in his city. To test this, he uses the antenna on his roof to measure the 5G level each day. However, he does not know how he should analyze the data. 

We are given the measurements for nn consecutive days as a list of numbers x_1,,x_nx\_1, \ldots, x\_n (where x_ix\_i denotes the measurement for day ii) and a constant cc that measures how much Åke expects the radiation to vary from day to day. We want to find, for each day ii, the most significant difference between the measurement on day ii and any earlier day, after the expected variations are taken into account. More precisely, the goal is to find the maximum value of \[|x_i-x_j| - c \cdot |i-j|\] where jij \le i.  I.e., we want to find a large difference in 5G level that has happened recently.

입력

The first line of input contains the two integers nn and cc (1n41051 \le n \le 4 \cdot 10^5, 1c1061 \le c \le 10^6), the number of measurements and expected day-to-day variation. The second input line contains the nn integers x_1,x_2,,x_nx\_1,x\_2,\dots,x\_n (1x_i1061 \le x\_i \le 10^6 for i=1,2,,ni=1,2,\dots,n), giving the measurements of the nn days.

출력

Output nn integers y_1,,y_ny\_1, \ldots, y\_n, where y_iy\_i is the most significant difference on day ii.