410031: GYM103921 C Earthbending years

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

Description

C. Earthbending yearstime limit per test1.0 smemory limit per test256 megabytesinputstandard inputoutputstandard output

It is Earth Kingdom tradition to track the year with some piles of raised earth. To mark the new year, earthbenders come together to raise the ground $$$1$$$ unit, representing the new year.

Unfortunately, they can only raise the dirt from its initial height of $$$0$$$ to a maximum height of $$$3$$$ (since they lack proper training). As a solution, when a pile needs to be raised to a height of $$$4$$$, instead they gently lower the pile back to a height of $$$0$$$ and raise the area to the right by $$$1$$$ unit of height.

There are currently $$$N$$$ piles, representing the current year. Given the state of the dirt piles, determine what the piles would look like in $$$K$$$ years.

Input

Two space-separated numbers, $$$1 \leq N \leq 1000$$$ and $$$1 \leq K \leq 10^4$$$.

The next $$$N$$$ numbers represent the current pile heights from left to right, where the last pile is guaranteed to have non-zero height.

Output

The piles after $$$K$$$ years, from left to right, where the last pile has non-zero height.

ExamplesInput
3 6
3 2 2
Output
1 0 3 
Input
1 21
2
Output
3 1 1 

加入题单

算法标签: