QOJ.ac

QOJ

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

#10240. 考试 [A]

统计

Marysia 参加了一场由 $n$ 个问题组成的考试。每个问题的回答评分如下:

  • 答对得 $1$ 分,
  • 不回答得 $0$ 分,
  • 答错得 $-1$ 分。

要通过考试,必须获得至少 $t$ 分。

对于每个问题,Marysia 都确定了一个潜在的答案,但她并不总是确定该答案是否正确。具体来说,对于第 $i$ 个问题,她知道答案正确的概率为 $p_i$。不同问题答案的正确性是相互独立的事件。

Marysia 必须选择回答哪些问题,以及放弃回答哪些问题,以最大化她通过考试的概率。

输入格式

输入的第一行包含两个整数 $n, t$ ($1 \le t \le n \le 50\,000$):问题的数量和所需的最低分数。

接下来的 $n$ 行包含答案正确的概率:其中第 $i$ 行包含一个实数 $p_i$ ($0 \le p_i \le 1$),该数小数点后最多有 $9$ 位数字。

输出格式

输出一行,包含一个实数:如果 Marysia 做出最优选择,她通过考试的概率。该数字必须以十进制(非科学计数法)形式输出,小数点后最多保留 $20$ 位。

最大允许绝对误差为 $10^{-6}$。

样例

输入 1

5 2
0.77
0.85
0.75
0.98
0.6

输出 1

0.8798125

输入 2

5 3
0.3
0.01
0.2
0.15
0

输出 2

0.009

输入 3

3 3
0.000001
0.000001
0.000001

输出 3

0

说明

在第一个样例中,最优策略是回答前 $4$ 个问题,而不回答最后一个问题。这样,即使有一个错误答案,Marysia 也能获得 $2$ 分。

在第二个样例中,最优策略是回答第 $1$ 个、第 $3$ 个和第 $4$ 个问题。如果所有这些回答都正确,Marysia 将获得 $3$ 分。由于这些事件是独立的,概率为 $0.3 \cdot 0.2 \cdot 0.15 = 0.009$。

在最后一个样例中,成功的概率为 $10^{-18}$,我们可以将其四舍五入为 $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.