[Huawei Computer Test Real Questions Python] Bonus Points

Question description

The company owner has made a big business and wants to allocate some bonuses to each employee. He wants to use a game to determine how much money each person will get.
According to the order of employees’ job numbers, each person randomly selects a number.
Arrange in order of employee numbers. If the first number is greater than your own number, then the employee in front can get a bonus of "distance * number difference".
If you don’t encounter a number larger than your own, assign yourself a random number as a bonus.
For example, the random numbers in order of job numbers are: 2,10,3.
Then the number 10 of the second employee is greater than the number 2 of the first employee,
Therefore, the first employee can get 1*(10-2 )=8. There is no employee with a larger number behind the second employee,
Therefore, he gets the bonus of the random number he assigned, which is 10.
The third employee is the last employee, and there is no employee with a larger number behind him, so the bonus he gets is 3.

Please help the boss calculate how much bonus each employee will receive in the end.

Enter description

  • The first line n represents the number of employees (including the last boss)
    The second line is the random number assigned to each employee

Output description

  • The final number of bonuses distributed to each employee

    Note: The random numbers do not repeat. The number of employees (including bosses) ranges from 1 to 10,000. The random number ranges from 1 to 100,000.

Reference example

Example 1

enter

3
2 10 3


Output    

8 10 3


Reference Code

# 输入获取
m = int(in

Guess you like

Origin blog.csdn.net/forest_long/article/details/135031679