#P7761. Maximize Deposit Percentage Difference
Maximize Deposit Percentage Difference
Maximize Deposit Percentage Difference
You are given the deposits of N bank customers. Your task is to find two real numbers \(A\) and \(B\) such that exactly \(A\%\) of the customers hold exactly \(B\%\) of the total deposit, and the difference \(B-A\) is maximized.
In other words, if you select the top \(k\) customers (after sorting the deposits in descending order) then:
[ A = \frac{100 \cdot k}{N}, \quad B = \frac{100 \cdot (\text{sum of top } k \text{ deposits})}{\text{total sum of deposits}}. ]
You need to choose an integer \(k\) (with \(1 \le k \le N\)) such that \(B-A\) is maximized. If there are multiple possible choices, choose the one encountered first when iterating \(k\) from 1 to \(N\). Finally, output the two numbers \(A\) and \(B\), each formatted to 6 decimal places.
inputFormat
The first line contains an integer \(N\) representing the number of bank customers.
The second line contains \(N\) space-separated numbers representing the deposit amounts of each customer.
outputFormat
Output two real numbers \(A\) and \(B\) separated by a space. Each number should be printed with 6 decimal places.
sample
5
1 1 1 1 1
20.000000 20.000000