Safety in Numbers (Small)
Time limit5sMemory limit512 MB
Each contestant needs the smallest audience vote share that keeps them from ever finishing as the single lowest scorer.
- Level
Medium6 of 10
- Topics
- Binary search, Math
- Solved
- No attempts yet
Problem
A reality TV show has contestants. The judges give contestant an integer score . The audience then splits its vote among the contestants: contestant takes a fraction of the audience vote, every is between 0 and 1 inclusive, and .
Let . The final score of contestant is .
The contestant with the lowest final score is eliminated. If two or more contestants tie for the lowest final score, nobody is eliminated.
Contestant is safe at a given when no way of splitting the remaining of the audience vote among the other contestants eliminates contestant . For each contestant, find the smallest that makes the contestant safe, written as a percentage.
Input
The first line has one integer , the number of test cases. Each of the next lines holds one test case: the number of contestants , then integers , all separated by single spaces. The integer is the score the judges gave contestant .
Limits
- for at least one , so .
Output
For each test case print one line: Case #x: followed by numbers separated by single spaces. Here is the case number starting from 1, and is the smallest percentage of the audience vote that makes contestant safe.
Print each with exactly six digits after the decimal point, rounding a value that lands exactly halfway upward. Every is a rational number, and no test case has an answer sitting on a rounding boundary, so ordinary fixed-point printing of a correctly computed answer matches.