Core Training (Small2)

Distribute U training units among N cores, each unit adding 1 to a core's success probability (capped at 1), to maximize the chance that at least K cores succeed.

Hard8Dynamic programmingGreedyProbabilityBrute forceNo attempts yetTime limit5sMemory limit512 MB

Problem

Writing contest problems is hard, so we built an AI that comes up with new ideas for us. To make the AI as creative as possible, we gave it NN different cores, each with its own personality. Just like people, these cores may get distracted or corrupt or may refuse to work. The ii-th core has a success probability PiP_i of functioning properly. As long as at least KK of the cores function properly, the AI functions properly. Otherwise it probably becomes evil and traps us in a maze of fiendish puzzles of its own design. Who knows what it might do to the contest. It might write a pile of tough probability problems.

To prevent that, we plan to train one or more of the cores to become more reliable. We have UU training units in total. Spending XX units on the ii-th core adds XX to its success probability. We can divide the units among the cores however we like, and some cores may receive no units at all. A success probability can never be raised above 11.

If we assign the training units so that the probability that the AI functions properly is as large as possible, what is that probability?

Input

The first line of the input gives the number of test cases, TT. TT test cases follow, and each one consists of three lines.

The first line contains two integers NN and KK: the total number of cores, and the minimum number of cores that must succeed for the AI to function properly. The second line contains one rational number UU, the number of training units. The third line contains NN rational numbers, the ii-th of which is the probability PiP_i that the ii-th core functions properly. UU and every probability are given with exactly four digits after the decimal point.

Limits

  • 1T1001 \le T \le 100
  • 1N501 \le N \le 50
  • 1KN1 \le K \le N
  • 0.0000Pi1.00000.0000 \le P_i \le 1.0000 for all ii
  • 0.0000UN(P1+P2++PN)0.0000 \le U \le N - (P_1 + P_2 + \dots + P_N) (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 xx is the test case number starting from 1 and yy is the probability that the AI functions properly when the training units are assigned optimally. Round yy at the seventh digit after the decimal point and print exactly six digits after the decimal point. For a probability of 0.250.25 print 0.250000, and for a probability of 11 print 1.000000.

Hint

In the first test case of the sample, we have enough training units to give every core a success probability of 1, so the AI certainly functions properly.

In the second test case, both cores must function properly, so each core needs some training units. The best option is to train each one up to 0.50.5, which gives a probability of 0.5×0.5=0.250.5 \times 0.5 = 0.25. Every other assignment is worse. Training one core to 0.90.9 and the other to 0.10.1 gives only 0.090.09.

In the third test case there are no training units to spend, and at least one of the two cores must function properly. The AI fails only when both cores fail, and that happens with probability (10.9)×(10.8)=0.02(1 - 0.9) \times (1 - 0.8) = 0.02, so the answer is 10.02=0.981 - 0.02 = 0.98.

In the fourth test case the best strategy is to give all the training units to the second core. That makes the probability that at least one core functions properly 1(0.6×0.4)=0.761 - (0.6 \times 0.4) = 0.76. All other options are worse: giving all the units to the first core yields 0.750.75, and dividing them equally between the cores gives 0.75250.7525.