Income Inequality
Time limit2sMemory limit1024 MB
Given n household wealth values, find the maximum of y minus x, where the top x percent of households hold y percent of total wealth.
- Level
Medium5 of 10
- Topics
- Sorting, Prefix sum, Greedy
- Solved
- No attempts yet
Problem
According to Wikipedia, in 2021, the top 1% of households owned 32.3% of the wealth in the United States. More generally, for any percentage , the data may show that the top of households own of the wealth.
For any society with some inequality, holds except when and . Among all possible values of , what is the maximum value of ?
Given the incomes of all people in a society, find the maximum value of such that the top of people hold of the society's wealth.
Input
The first line contains a single integer (), the number of people in the society.
The second line contains integers. Each integer () is the wealth of one household. The values are not necessarily distinct.
Output
Print the maximum possible value of , where the top of households own of the society's wealth. An answer is accepted if its absolute or relative error is within .