#QHD0000056. Liên minh cổ đông (Best Coalitions)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Liên minh cổ đông (Best Coalitions)
Best Coalitions
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
A company has shareholders. Shareholder owns exactly percent of the voting shares, represented using two digits after the decimal point. The percentages sum to exactly .
Under the company profit-sharing rule, a shareholder or a coalition receives the entire previous year's profit if it owns strictly more than of the shares. Shareholder (numbered from ) must belong to the coalition. Each of the other shareholders may independently join or stay out.
Each winning coalition member receives profit in proportion to their share ownership within that coalition. The percentage of the company profit received by shareholder is divided by the sum of the coalition members' ownership percentages. Find the maximum percentage of profit for shareholder . A coalition owning exactly does not win; selecting all shareholders is always allowed.
Input
The first line contains integers . The next lines each contain , formatted with exactly two digits after the decimal point (for example 12.34). Shareholder indices start at .
Output
Print the maximum percentage of profit received by shareholder in a winning coalition, as a percentage with exactly two digits after the decimal point.
Subtasks
-
Subtask 1 (20 points): , , every has exactly two fractional digits, and .
-
Subtask 2 (30 points): , , every has exactly two fractional digits, and .
-
Subtask 3 (50 points): , , every has exactly two fractional digits, and .
Examples
Input
3 1
40.00
20.00
40.00
Output
66.67
Explanation
Shareholder owns and cannot win alone. Joining shareholder (who owns ) yields in total, so the profit share is , printed as 66.67. Joining shareholder gives only relative power, while joining both gives . The first coalition is optimal.