409713: GYM103698 C The 80/20 Rule

Memory Limit:512 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. The 80/20 Ruletime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard output

The law of twenty-eight (the Pareto law) is also known as the law of 80/20, and it is also called Barrett's law, Julen's law, the law of the critical minority, the law of the unimportant majority, the law of the least effort, the principle of imbalance. It is widely used in Sociology and business management. It was discovered by Pareto, an Italian economist in the late 19th and 20th centuries. He believes that in any set of things, the most important part only accounts for a small part of it, about $$$20 \%$$$ , and the remaining $$$80\%$$$, although in the majority, is secondary, so it is also known as the law of twenty-eight.

A popular example is that, the $$$80\%$$$ of the wealth in the world is owned by the $$$20\%$$$ of the people. Now I want you to write a program to check that, for a given set of bank accounts, whether the stored balances is strictly not weaker than the law of twenty-eight. The test method is to find two real numbers $$$A$$$, $$$B$$$, and the $$$A\%$$$ of the people own the $$$B\%$$$ of the wealth, and $$$B - A$$$ is maximized.

Input

The first line contains an integer $$$n$$$, indicating that we have the stored balances of $$$n$$$ accounts.

The second line contains $$$n$$$ integers $$$a_1, \dots, a_n$$$, which respectively represents the stored balance of each account.

Output

The first line contains two real numbers (the result is rounded to two decimal places), representing $$$A$$$, $$$B$$$ respectively.

If more than one pair of $$$(A, B)$$$ can maximize $$$B - A$$$, please output the answer with the largest $$$A$$$.

ExamplesInput
13
411 5622 3638 3411 5069 693 2738 3757 2496 2861 6761 355 1839
Output
46.15 71.27
Input
2
10 10
Output
100.00 100.00
Note

Subtask 1 (20pts): $$$1 \leq n \leq 20$$$

Subtask 2 (40pts): $$$1 \leq n \leq 1000$$$

Subtask 3 (40pts): $$$1\leq n\leq 10^5, 1 \leq a_i \leq 10^4$$$

For $$$100\%$$$ data, it's guaranteed that $$$1\leq n\leq 10^5, 1 \leq a_i \leq 10^4$$$

In the first set of examples, the stored balances of individuals $$$2, 3, 4, 5, 8, 11$$$ are $$$5622, 3638, 3411, 5069, 3757, 6761$$$, and their total balance is $$$28258$$$. The total balance of all people is $$$39651$$$. Therefore, these selected people, who have $$$28258/39651 \approx 71.27\%$$$ of the wealth, correspond to $$$6/13 \approx 46.15\%$$$ of all people.

In the second set of examples, there are three possible sets of $$$(A, B)$$$, namely $$$(0, 0), (50, 50), (100, 100)$$$: their corresponding $$$B - A$$$ are all $$$0$$$. Therefore, according to the problem statement, you need to output the answer with the largest $$$A$$$, namely $$$(100, 100)$$$.

加入题单

上一题 下一题 算法标签: