A fusion test facility has n reactor cores arranged in a line, each with an initial power rating. An automated rebalancing routine runs for exactly k cycles. In every cycle, the routine finds the core with the currently lowest power rating -- choosing the leftmost such core if several cores are tied for lowest -- and multiplies that core's power rating by a fixed booster factor, permanently increasing it.
After all k cycles have run, report the final power rating of every core, in their original left-to-right order.
Line 1: three integers n, k, and multiplier.
Line 2: n integers, the initial power ratings, in core order.
A single line with n space-separated integers: the final power rating of each core, in original order.
Example 1
Input
4 3 2 2 5 6 3
Expected
8 5 6 6
Explanation
Start [2,5,6,3]. Cycle 1: minimum is 2 at index 0, becomes 4 -> [4,5,6,3]. Cycle 2: minimum is 3 at index 3, becomes 6 -> [4,5,6,6]. Cycle 3: minimum is 4 at index 0, becomes 8 -> [8,5,6,6]. Final: 8 5 6 6.
Example 2
Input
3 2 3 1 1 1
Expected
3 3 1
Explanation
Start [1,1,1], all tied. Cycle 1: leftmost minimum is index 0, becomes 3 -> [3,1,1]. Cycle 2: minimum is now 1, tied between indices 1 and 2, leftmost is index 1, becomes 3 -> [3,3,1]. Final: 3 3 1.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →