All problems

Cumulative Share of Revenue by Rank

hardPythonNumPynp.cumsum

Riverbend Supply's board wants to see how concentrated its revenue is. The classic view lines the products up with the biggest earner first and asks how much of the year's revenue the top one accounts for, then the top two together, then the top three, and so on until every product is included and the figure reaches one hundred percent. A board that sees ninety percent covered by the first two products manages the business very differently from one that needs twenty products to get there.

Task: Print the cumulative share of total revenue, taking the products from the biggest earner downwards.

Input

The first line holds a single integer n, the number of products. Each of the next n lines holds one product's revenue for the year, which may carry decimals. The figures arrive in no particular order.

Output

One line holding n percentages, separated by single spaces, each with one digit after the decimal point. The first is the largest product's share of the total, and each later figure includes every product before it. The last is always 100.0.

Example:

Input:
3
100
300
600

Output:
60.0 90.0 100.0

Sign in to solve this problem

Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.

Sign in

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…