問題一覧 > 通常問題

No.210 Where Is the Thing You're Looking For?

レベル : / AI推定難易度 : 1850 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 小数誤差許容問題 絶対誤差または相対誤差が $10^{-3}$ 以下。ただし、ジャッジ側の都合で500桁未満にしてください
タグ : (AC するまで非表示) / 解いたユーザー数 77
作問者 : autotaker1984
お気に入りにしたユーザー ProblemId : 483 / 自分の提出
問題文最終更新日: 2026-06-30 05:25:47
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 104 (順位表) の他の問題:

Problem Statement

Detective Cordelia has been asked by an old gentleman to search for his lost glasses.
The old gentleman's mansion has $n$ rooms, numbered from $1$ to $n$. It is known that the probability that the glasses were lost in the $i$-th room is $\frac{p_i}{1000}$.
Also, the rooms are very messy, so even if the glasses are in a room, searching it once does not necessarily mean they will be found.
When the glasses are in the $i$-th room, the probability of finding them by searching that room once is $\frac{q_i}{100}$, regardless of how many times that room has been searched in the past.

Cordelia wants to find the glasses while searching rooms as few times as possible, because she is going to attend Marine's live concert.
To help Cordelia, minimize the expected number of times rooms are searched until the glasses are found.

Input

$n$
$p_1\ p_2\ \dots\ p_n$
$q_1\ q_2\ \dots\ q_n$


The first line gives the number of rooms.
The second line gives $n$ integers. Each is the probability that the glasses were lost in the corresponding room, multiplied by 1000.
The third line gives $n$ integers. Each is the probability of finding the glasses by searching the corresponding room once, multiplied by 100.
$1 \leq n \leq 1000$
$0 \leq p_i \leq 1000$
$1 \leq q_i \leq 100$
$\sum_{i = 1}^n p_i = 1000$

Output


Output the minimum expected number of times Cordelia searches rooms until she finds the glasses. A relative or absolute error of up to 0.001 is allowed.
Print a newline at the end.

Sample

Sample 1
Input
1
1000
50
Output
2.0


In this example, there is only one room to search.
The expected value in this case is $E = \sum_{k=1}^{\infty} k 0.5^{k} = 2$.

Sample 2
Input
10
100 100 100 100 100 100 100 100 100 100
100 100 100 100 100 100 100 100 100 100
Output
5.5


In this example, searching each room once is guaranteed to find the glasses.
Since the glasses are equally likely to be in any room,
the expected value does not change regardless of the order in which Cordelia searches the rooms.

Sample 3
Input
10
64 201 4 30 232 64 197 7 102 99
28 43 94 52 24 33 97 55 36 89
Output
12.277056

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。