Statistics
Time limit1.5sMemory limit256 MB
Pick the fewest courses whose units sum to exactly V, then find the minimum average, median, highest repeat count, and max-min range over those schedules.
- Level
Medium6 of 10
- Topics
- Dynamic programming, Sorting, Implementation
- Solved
- No attempts yet
Statistics
You are choosing courses for your last semester of university. There are courses available, numbered from through . Course is worth units, and you need at least units to graduate. Because you want more time to train for ACM ICPC, you want to choose a subset of courses that gives exactly units. You also want to choose the fewest courses possible, so you spend less time walking around campus. Such a subset is called a good schedule.
You want to pick among all good schedules with the help of some statistics. For each good schedule, view it as a list of the units of its courses and calculate the following values.
- : the average value.
- : the median value. If the list has an even length, use the smaller of the two middle values.
- : the maximum number of times a single value appears.
- : the difference between the maximum value and the minimum value.
For each of , , , and , find its minimum over all good schedules.
Input
The first line contains two integers, and : the number of courses and the number of units you need to graduate ().
The next line contains integers , the number of units in each course ().
Output
Print four space-separated real numbers: the minimum , , , and over all good schedules, in that order. Your answer must have an absolute or relative error less than . If there are no good schedules, print a single integer instead.