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は、試験に合格する確率を最大化するために、どの問題に回答し、どの問題を無回答にするかを選択しなければなりません。

入力

入力の最初の行には、2つの整数 $n, t$ ($1 \le t \le n \le 50\,000$) が含まれます。これは問題数と合格に必要な最低点数です。

続く $n$ 行には、回答が正解である確率が記載されています。$i$ 番目の行には実数 $p_i$ ($0 \le p_i \le 1$) が含まれており、小数点以下は最大9桁です。

出力

出力の唯一の行には、Marysiaがどの問題に回答するかを最適に選択した場合の、試験に合格する確率を1つの実数で出力してください。数値は(指数表記ではなく)10進法で、小数点以下最大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問に回答し、最後の1問を無回答にすることです。こうすることで、1問間違えたとしてもMarysiaは2点を獲得できます。

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.