# | Problem | Pass Rate (passed user / total user) |
---|---|---|
13850 | Hadas Eating Macarons |
|
Description
An hadas is playing a game with you! In this game, there are 10 plates of macarons. These 10 plates are arranged in a circle and labeled from 1
to 10
in clockwise order. There will be a total of 100 rounds in this game. In each round, the following actions are performed in order:
-
Select the current plate:
- In the first round, the current plate is the one labeled
1
. - In subsequent rounds, the current plate label = (last round’s target plate label) % 10 + 1.
- In the first round, the current plate is the one labeled
-
Remove plates: Hadas temporarily removes the 3 plates following the current plate in a clockwise direction.
-
Select the target plate: Based on the following rules, select the target plate:
- The candidate plates have smaller number of macarons than the current plate. From the candidate plates, choose the one with the most macarons.
- If the current plate has the fewest macarons, select the plate with the most macarons.
- If multiple plates have the same number of macarons, choose the one closest (least hops away, clockwise or counterclockwise) to the current plate. If two plates are equidistant from the current plate, select the one in a clockwise direction. For example, from the following figure, we will choose the shorter distance 1 instead of the longer one 7.
-
Eat macarons: Hadas eats k macarons from the target plate, where k equals the target plate’s label. If the plate has fewer macarons than k, add 50 macarons to the plate first so Hadas can still do eating.
-
Put back the removed plates: Reverse the removed three plates and place them back in the circle after the target plate in clockwise order.
After completing 100 rounds, please provide the final order of the plates (starting with the last round’s target plate) in clockwise order and the remaining number of macarons on each plate.
Input
- There are 10 lines of input in total. Each input represents the initial number of macarons (
n
) on the plate. - The input order will be entered according to the label order of the plate from
1
to10
. - 0<=n<=1000, n∈N.
Output
- The final order of the plates (starting with the last round’s target plate) in clockwise order.
- The remaining number of macarons on each plate.