This Is Sparta!

시간 제한1초메모리 제한2048 MB

요약
생명력 값을 가진 N명의 검투사가 있을 때, K번의 라운드마다 생명력을 기준으로 정렬하고 각 검투사가 자신의 생명력을 다음 검투사의 생명력에서 빼는 과정을 반복한 후, 현재 줄 순서대로 최종 생명력을 출력한다.
난이도

어려움10점 중 8점

유형
정렬, 시뮬레이션, 수학
정답자
아직 제출이 없습니다

문제

King Primonidas is putting together a tournament to find the strongest gladiator in all the lands. In total NN gladiators have made their way to the Coliseum to bring back honor and glory to their hometowns. Each gladiator starts with a certain amount of vitality. Vitality is similar to health points in that it reflects the amount of damage a gladiator can take, but it also represents the amount of damage they can deal (since energy is needed for strong blows).

The tournament consists of KK rounds. Every round, the king arranges the gladiators in a line from least to most remaining vitality, breaking ties randomly. King Primonidas believes that the true strength of a gladiator lies in their ability to take a beating, so he orders the first gladiator (the one with the lowest remaining vitality) to deal their strongest blow to the second gladiator. This blow subtracts the first gladiator's vitality from the second gladiator's vitality. After the second gladiator takes the hit, they deal their strongest blow (using their new, lowered vitality) to the third gladiator, and so on. This process repeats until the second-to-last gladiator deals their strongest blow to the last gladiator (who doesn't get to attack anybody).

Notice that in the above process, a gladiator's vitality can never go below zero. (A gladiator with zero vitality deals a feeble blow of no damage to the next gladiator.)

Print the vitality of each gladiator after KK tournament rounds, in order from the first to the last gladiator in line.

입력

The first line of input contains two space-separated integers NN (2≤N≤1052 \leq N \leq 10^5) and KK (1≤K≤10181 \leq K \leq 10^{18}): the number of gladiators and the number of rounds in the tournament.

The next line of input contains NN space-separated integers v_1v_2…v_Nv\_1 v\_2 \ldots v\_N (0≤v_i≤10180 \leq v\_i \leq 10^{18}): the starting vitality of the gladiators.

출력

Print NN space-separated integers: the vitality of the gladiators at the end of the KKth round of the tournament, in the order that the gladiators currently stand in line.

예제2

  1. 예제 1

    입력
    6 3
    21 28 24 23 1 12
    
    예상 출력
    1 1 3 6 3 10
    
  2. 예제 2

    입력
    3 1000
    8 2 10
    
    예상 출력
    0 0 2