Core Training (All Cores)

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.

Medium5GreedyMathProbabilityImplementationInterviewNo attempts yetTime limit5sMemory limit512 MB

Problem

An AI runs on NN 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 ii works properly with probability PiP_i. If at least KK 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 UU training units in total. Spending XX units on core ii raises that core's success probability by XX. 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 11.

Compute the probability that the AI works properly when the training units are assigned optimally.

In this problem K=NK = N always holds. If even one core fails, the AI does not work properly.

Input

The first line contains the number of test cases TT. Then TT test cases follow, each on three lines. The first line contains two integers NN and KK: the number of cores, and the minimum number of cores that must succeed for the AI to work properly. The second line contains UU, the total amount of training units. The third line contains NN numbers, the ii-th of which is the success probability PiP_i of core ii. Both UU and every PiP_i are written with exactly four digits after the decimal point.

Limits

  • 1T1001 \le T \le 100
  • 1N501 \le N \le 50
  • 0.0000Pi1.00000.0000 \le P_i \le 1.0000 for every ii
  • 0.0000UNi=1NPi0.0000 \le U \le N - \sum_{i=1}^{N} P_i (there are never more training units than can be used)
  • K=NK = N

Output

For each test case, print one line of the form Case #x: y, where xx is the test case number starting from 1 and yy is the probability that the AI works properly under an optimal assignment of the training units.

Print yy 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 11 prints as 1.000000, and 1/41/4 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 11, so the answer is 11.

In the second case of the first example both cores have to succeed, so both of them get units. Raising each one to 0.50.5 is best and gives 0.5×0.5=0.250.5 \times 0.5 = 0.25. Training one core to 0.90.9 and the other to 0.10.1 yields only 0.090.09.

In the third case of the second example all 0.20.2 units go to the weaker core, raising 0.10.1 to 0.30.3. The answer is 0.3×0.9=0.270.3 \times 0.9 = 0.27. Giving every unit to the stronger core wastes part of them because a probability cannot exceed 11, which leaves 0.1×1.0=0.10.1 \times 1.0 = 0.1, and splitting the units evenly gives 0.2×1.0=0.20.2 \times 1.0 = 0.2.