QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 1024 MB مجموع النقاط: 100

#4994. 毕业保证

الإحصائيات

Gustav 正在学习成为一名口译员。在这一行,掌握多种语言是必须的,Gustav 已经精通法语、普通话、纳瓦特尔语,甚至是芬兰语。但有一门语言让 Gustav 很头疼:挪威语。在毕业之前,他必须通过臭名昭著的“挪威语总结性能力测试”。

Picture by Milford, public domain

这场考试包含 $n$ 道是非题。回答正确得 $+1$ 分,回答错误得 $-1$ 分,不回答得 $0$ 分。要通过考试,至少需要 $k$ 分。对于每一道题,Gustav 有一个猜测,他认为该猜测正确的概率为 $p_i$ ($0.5 \le p_i \le 1$)。注意 $p_i \ge 0.5$,因为否则猜测相反的答案会更好。

假设我们仔细选择哪些题目要回答,哪些题目不回答,通过考试的最大可能概率是多少?注意,与程序设计竞赛不同,这场考试没有即时反馈。因此,Gustav 会先回答所有选定的题目,交卷,之后才会得知结果。

输入格式

第一行包含两个整数 $n$ 和 $k$ ($1 \le k \le n \le 5000$)。第二行包含 $n$ 个实数 $p_i$ ($0.5 \le p_i \le 1.0$)。这些数字小数点后最多有 6 位。

输出格式

输出通过考试的概率。如果你的答案与标准答案的绝对误差或相对误差不超过 $10^{-6}$,则被视为正确。

样例

输入格式 1

3 3
0.5 0.5 0.5

输出格式 1

0.125

输入格式 2

4 1
0.9 0.5 0.9 0.9

输出格式 2

0.972

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.