Although this is a game, it is not a joke. (これは、ゲームであっても遊びではない)
── Kayaba Akihiko
Sword Art Online is a fully immersive VR game operates with NerveGear, which completely controls the player's consciousness by redirecting the signals the brain sends to the body and sending its own waves to stimulate the five senses.
Kirito, known as the Black Swordsman, is the fastest player in SAO. He is so fast that he even get the hidden skill named nitoryu (二刀流), which will be given to the fastest player.
He solos a lot, beats lots of monsters, gains huge amounts of experiences, and levels up. Now, he has some skill points to spend.
He wants to become faster and faster, so he would like to spend all skill points to level up those speed-based skills, and he needs to find out the best strategy in order to get the maximum speed he can reach.
Although he is a solo player, he still asks you for help. Please help him find out the best strategy so that he can equip his second sword and cast Star Burst Stream in 10 seconds.
Kirito casting "Star Burst Stream"
There are exactly skills. The maximum level of each skill is . The initial level of Kirito's skills are . And the number of skill points that he can spend is . The formula of calculating speed is:
where is given. Note that if condition is true, otherwise.
Each skill points can increase the level of exactly one skill by (if it's not equal to yet). You are going to find out all , which is the level of -th skill after leveling up, such that the speed has maximum value.
Take sample as example:
Skill levels are initially , and we have skill points to spend.
The best strategy is to spend skill points ( skill points are spent) to the corresponding skill, and the skill levels will become .
The speed is:
The first line contains integers: , respectively.
The next line is the sequence , each number is separated by a space.
The first line should be the maximum value of .
The next line print integers separated by a space, where is the level of -th skill after spending skill points.
If there are multiple answers of , print any. All valid and correct answer will be accepted.