Core Training (All Cores)
InterviewTime limit5sMemory limit512 MB
With K = N, the AI works only if every core succeeds; split U training units among cores to maximize the product of final success probabilities.
- Level
Medium5 of 10
- Topics
- Greedy, Math, Probability, Implementation
- Solved
- No attempts yet
Problem
An AI runs on cores, and every core has a personality of its own. Like people, a core can get distracted, break down, or simply refuse to work. Core works properly with probability . If at least cores work properly, the AI works properly. Otherwise the AI starts doing something else entirely.
To stop that, you train some of the cores to make them more reliable. You have training units in total. Spending units on core raises that core's success probability by . You may split the units among the cores any way you like, in real amounts, and a core may receive nothing at all. A success probability can never rise above .
Compute the probability that the AI works properly when the training units are assigned optimally.
In this problem always holds. If even one core fails, the AI does not work properly.
Input
The first line contains the number of test cases . Then test cases follow, each on three lines. The first line contains two integers and : the number of cores, and the minimum number of cores that must succeed for the AI to work properly. The second line contains , the total amount of training units. The third line contains numbers, the -th of which is the success probability of core . Both and every are written with exactly four digits after the decimal point.
Limits
- for every
- (there are never more training units than can be used)
Output
For each test case, print one line of the form Case #x: y, where is the test case number starting from 1 and is the probability that the AI works properly under an optimal assignment of the training units.
Print with exactly six digits after the decimal point, rounding the seventh digit onward to the nearest value and rounding up on an exact half. Print all six digits even when they are zeros. A probability of prints as 1.000000, and prints as 0.250000.
Hint
In the first case of the first example there are enough training units to raise all four cores to probability , so the answer is .
In the second case of the first example both cores have to succeed, so both of them get units. Raising each one to is best and gives . Training one core to and the other to yields only .
In the third case of the second example all units go to the weaker core, raising to . The answer is . Giving every unit to the stronger core wastes part of them because a probability cannot exceed , which leaves , and splitting the units evenly gives .