407754: GYM102890 E End of the year bonus

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. End of the year bonustime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

The last month of the year is here and everybody loves this month for two reasons: holidays and end of year performance bonus.

It is believed that if an employee performed better than another employee, they must receive a bigger bonus.

Employees do not know each others performance, so they may not know if they are being underpaid. But, as every year, they figured out how to determine if they are being underpaid. $$$N$$$ employees will have a meeting sitting in a circular table, and each of them will ask the person sitting next to them (to their right, and their left) what their performance and bonus was. The employee sitting in chair $$$1$$$ is at the right of employee at chair $$$N$$$, also employee at chair $$$N$$$ is at the left of employee at chair $$$1$$$. And the $$$i$$$-th employee is at the right of the $$$(i-1)$$$-th employee, and to the left of the $$$(i+1)$$$-th employee.

Corporate knows employees do this, so this year they will adjust their bonus giving because they dont want to receive complaints. The will make sure that if an employee performed better than the person sitting next to them, they received a bigger bonus.

Corporate knows the chair where each of the $$$N$$$ employees is sitting, help them decide the bonus for each employee in such way that everyone is satisfied (is paid more if performed better than the person sitting next to them) using the less amount of money. The base bonus, for someone with no performance is 0, everyone knows that, and each bonus should be a multiple of $$$B$$$.

Input

The first line of input contains two integer numbers separated by a space $$$N$$$, and $$$B$$$ ($$$1 \leq N \leq 10^5$$$, $$$1 \leq B \leq 10^5$$$), representing, respectively the number of employees, and the number all bonuses should be multiples. The second line contains $$$N$$$ numbers separated by a space, where the $$$i$$$-th number represents the performance $$$p_i$$$ ($$$0 \leq p_i \leq 10^6$$$) for the employee that will sit in the $$$i$$$-th chair in the meeting.

Output

Print a line with $$$N$$$ integer numbers separated by a space. Where the $$$i$$$-th number represents the bonus that corporate should give to the employee sitting at chair $$$i$$$ in the meeting.

ExamplesInput
8 1
1 2 3 2 1 3 2 1
Output
1 2 3 2 1 3 2 1
Input
8 1
0 2 3 2 1 3 2 1
Output
0 1 3 2 1 3 2 1

加入题单

上一题 下一题 算法标签: