P7761 [COCI 2016/2017 #5] Pareto

Background

The Pareto principle says: in any group of things, the most important part accounts for only a small portion, while the rest, although the majority, is less important. For example, Microsoft found that fixing only $20\%$ of the bugs can reduce $80\%$ of the downtime. Also, studies show that $80\%$ of the wealth is held by $20\%$ of the people.

Description

You are given the deposits of $N$ bank customers. Find two real numbers $A, B$ such that exactly $A\%$ of the customers own exactly $B\%$ of the total deposits, and $B - A$ is maximized.

Input Format

The first line contains an integer $N$, the number of bank customers. The next line contains $N$ integers, in order, representing each customer's deposit.

Output Format

The first line outputs the required value $A$. The second line outputs the required value $B$. It is guaranteed that for the maximum $B - A$, the final answer is unique. Your output is considered correct if it differs from the answer by at most $0.01$.

Explanation/Hint

**[Sample 1 Explanation]** It is easy to see that the customer with deposit $200$ owns about $66.666667\%$ of the total deposits. **[Constraints]** For $100\%$ of the testdata, $1 \le N \le 3 \times 10^5$, and all deposits are non-negative integers not exceeding $10^8$. **[Hints and Notes]** **This problem is translated from [COCI 2016-2017](https://hsin.hr/coci/archive/2016_2017/) [CONTEST #5](https://hsin.hr/coci/archive/2016_2017/contest5_tasks.pdf) _T2 Pareto_.** **The score of this problem follows the original COCI setting, with a full score of $80$.** Translated by ChatGPT 5