luogu#P7761. [COCI 2016/2017 #5] Pareto

[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%20\% of the bugs can reduce 80%80\% of the downtime. Also, studies show that 80%80\% of the wealth is held by 20%20\% of the people.

Problem Description

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

Input Format

The first line contains an integer NN, the number of bank customers.

The next line contains NN integers, in order, representing each customer's deposit.

Output Format

The first line outputs the required value AA.

The second line outputs the required value BB.

It is guaranteed that for the maximum BAB - A, the final answer is unique.

Your output is considered correct if it differs from the answer by at most 0.010.01.

2
100 200
50.0
66.66666666666666
8
100100 10 100 1000 1 10100
90100 100100
37.5
96.28172769816027

Hint

[Sample 1 Explanation]

It is easy to see that the customer with deposit 200200 owns about 66.666667%66.666667\% of the total deposits.

[Constraints]

For 100%100\% of the testdata, 1N3×1051 \le N \le 3 \times 10^5, and all deposits are non-negative integers not exceeding 10810^8.

[Hints and Notes]

This problem is translated from COCI 2016-2017 CONTEST #5 T2 Pareto.

The score of this problem follows the original COCI setting, with a full score of 8080.

Translated by ChatGPT 5