Each contestant needs the smallest audience vote share that keeps them from ever finishing as the single lowest scorer.
Medium6Binary searchMathNo attempts yetTime limit5sMemory limit512 MBA reality TV show has N contestants. The judges give contestant i an integer score si. The audience then splits its vote among the contestants: contestant i takes a fraction yi of the audience vote, every yi is between 0 and 1 inclusive, and y0+y1+⋯+yN−1=1.
Let X=s0+s1+⋯+sN−1. The final score of contestant i is si+Xyi.
The contestant with the lowest final score is eliminated. If two or more contestants tie for the lowest final score, nobody is eliminated.
Contestant i is safe at a given yi when no way of splitting the remaining 1−yi of the audience vote among the other contestants eliminates contestant i. For each contestant, find the smallest yi that makes the contestant safe, written as a percentage.
The first line has one integer T, the number of test cases. Each of the next T lines holds one test case: the number of contestants N, then N integers s0,s1,…,sN−1, all separated by single spaces. The integer si is the score the judges gave contestant i.
For each test case print one line: Case #x: followed by N numbers m0,m1,…,mN−1 separated by single spaces. Here x is the case number starting from 1, and mi is the smallest percentage of the audience vote that makes contestant i safe.
Print each mi with exactly six digits after the decimal point, rounding a value that lands exactly halfway upward. Every mi 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.