QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 1024 MB Total points: 10

#10240. Exam [A]

Statistics

Marysia is taking an exam consisting of $n$ questions. The answer to each question is graded as follows:

  • 1 point for a correct answer,
  • 0 points for no answer,
  • $-1$ point for an incorrect answer.

To pass the exam, one must score at least $t$ points.

For each question, Marysia has determined a potential answer, but she is not always certain if it is correct. Specifically, for the $i$-th question, she knows that the answer is correct with probability $p_i$. The correctness of answers for different questions are independent events.

Marysia must choose which questions to answer and which to leave unanswered in order to maximize the probability of passing the exam.

Input

The first line of input contains two integers $n, t$ ($1 \le t \le n \le 50\,000$): the number of questions and the required minimum number of points.

The next $n$ lines contain the probabilities of the answers being correct: the $i$-th of these lines contains a real number $p_i$ ($0 \le p_i \le 1$), which has at most 9 digits after the decimal point.

Output

The only line of output should contain a single real number: the probability that Marysia passes the exam if she chooses optimally which questions to answer. The number must be written in decimal notation (not scientific) with at most 20 decimal places.

The maximum allowable absolute error is $10^{-6}$.

Examples

Input 1

5 2
0.77
0.85
0.75
0.98
0.6

Output 1

0.8798125

Input 2

5 3
0.3
0.01
0.2
0.15
0

Output 2

0.009

Input 3

3 3
0.000001
0.000001
0.000001

Output 3

0

Note

In the first example, the optimal strategy is to answer the first 4 questions and leave the last one unanswered. In this way, even with one incorrect answer, Marysia will obtain 2 points.

In the second example, the optimal strategy is to answer the first, third, and fourth questions. Marysia will obtain 3 points if all these answers are correct. Since these events are independent, the probability is $0.3 \cdot 0.2 \cdot 0.15 = 0.009$.

In the last example, the probability of success is $10^{-18}$, which we can round to 0.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.