Pareto
Time limit1sMemory limit64 MB
Choose k accounts maximizing B minus A, where A = 100k/N and B is their share of all money as a percent.
- Level
Medium5 of 10
- Topics
- Greedy, Sorting, Math, Prefix sum
- Solved
- No attempts yet
Problem
Pareto's principle, also known as the "80/20 rule", states that in many situations 80% of results come from 20% of (the most important) causes. For instance, Microsoft found that by fixing 20% of the most commonly reported bugs, they would eliminate 80% of downtime in their systems. In the business world, it is often said that 80% of income comes from 20% of the most important clients. In mobile games with free basic functionality, 50% of profit comes from 0.5% of players. Some say that 80% of your success will come from 20% of your activities.
It is a known fact that 80% of the world's goods is owned by 20% of (the richest) people. Your task is to check the validity of this rule based on the bank accounts of the clients of a single bank. Is it true that 20% of accounts hold 80% of the total money? Does a stronger claim hold, for instance, that only 10% of accounts hold 85% of the total money?
More precisely: given the account balances of bank clients, find numbers and with the maximal difference such that we can say that precisely % of accounts hold % of the total money of all clients of the bank.
If you pick accounts (), then , and is the sum of the chosen balances divided by the sum of all balances, times 100. If several account counts give the maximal , choose the smallest such .
For example, with two accounts holding 100 and 200 euros, 50% of accounts (one account, the one with 200 euros) hold two thirds, 66.666667%, of the total money.
Input
The first line contains the integer (), the number of clients in the bank.
The second line contains integers, the balances of the bank accounts in euros. Each balance is between and inclusive, and at least one balance is positive.
Output
Print on the first line and on the second line, without the percentage sign.
Round both values to exactly six digits after the decimal point. When the remaining part is exactly one half, round up. For example, is printed as 0.195313.