#P11918. Maximize Passing Probability
Maximize Passing Probability
Maximize Passing Probability
You are given an exam with (n) questions. For each question (i), you can choose whether to answer it. If you answer, you get it correct with probability (p_i) and receive ( +1 ) point, or get it wrong with probability (1-p_i) and incur a penalty of ( -1 ) point. If you do not answer a question, you receive (0) points. All questions are independent. Your goal is to achieve at least (t) points (i.e. pass the exam). Under the condition that you can freely choose which questions to answer, determine the maximum probability of passing the exam. In other words, choose an optimal subset of questions to answer (and skip the others) such that the probability of obtaining a total score (S \ge t) is maximized.
inputFormat
The first line contains two integers (n) and (t), where (n) is the number of questions and (t) is the minimum score required to pass. The second line contains (n) real numbers (p_1, p_2, \dots, p_n) (with (0 \le p_i \le 1)) representing the probability of correctly answering question (i) if attempted.
outputFormat
Output a single real number representing the maximum probability of passing the exam. Your answer will be accepted if its absolute or relative error does not exceed (10^{-6}).
sample
3 1
0.7 0.2 0.5
0.73