Codeforces Round 980 (Div. 2)
F
Many Games
Codeforces
未评级
原题
← E→
翻译中…

Recently, you received a rare ticket to the only casino in the world where you can actually earn something, and you want to take full advantage of this opportunity.

翻译中…

The conditions in this casino are as follows:

翻译中…
  • There are a total of $n$ games in the casino.
  • You can play each game at most once.
  • Each game is characterized by two parameters: $p_i$ ($1 \le p_i \le 100$) and $w_i$ — the probability of winning the game in percentage and the winnings for a win.
  • If you lose in any game you decide to play, you will receive nothing at all (even for the games you won).
翻译中…

You need to choose a set of games in advance that you will play in such a way as to maximize the expected value of your winnings.

翻译中…

In this case, if you choose to play the games with indices $i_1 \lt i_2 \lt \ldots \lt i_k$, you will win in all of them with a probability of $\prod\limits_{j=1}^k \frac{p_{i_j}}{100}$, and in that case, your winnings will be equal to $\sum\limits_{j=1}^k w_{i_j}$.

翻译中…

That is, the expected value of your winnings will be $\left(\prod\limits_{j=1}^k \frac{p_{i_j}}{100}\right) \cdot \left(\sum\limits_{j=1}^k w_{i_j}\right)$.

翻译中…

To avoid going bankrupt, the casino owners have limited the expected value of winnings for each individual game. Thus, for all $i$ ($1 \le i \le n$), it holds that $w_i \cdot p_i \le 2 \cdot 10^5$.

翻译中…

Your task is to find the maximum expected value of winnings that can be obtained by choosing some set of games in the casino.

翻译中…

Input

翻译中…

The first line contains a single integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the number of games offered to play.

翻译中…

The $i$-th of the following $n$ lines contains two integers $p_i$ and $w_i$ ($1 \leq p_i \leq 100$, $1 \leq w_i, p_i \cdot w_i \leq 2 \cdot 10^5$) — the probability of winning and the size of the winnings in the $i$-th game.

翻译中…

Output

翻译中…

Output a single number — the maximum expected value of winnings in the casino that can be obtained by choosing some subset of games.

翻译中…

Your answer will be accepted if the relative or absolute error does not exceed $10^{-6}$. Formally, if $a$ is your answer and $b$ is the jury's answer, it will be accepted if $\frac{|a-b|}{\max(b, 1)} \le 10^{-6}$.

翻译中…

Note

翻译中…

In the first example, you can choose the first and third games. In this case, the expected value of winnings will be $\left(\frac{p_1}{100}\cdot \frac{p_3}{100}\right) \cdot (w_1 + w_3) = \left(\frac{80}{100}\cdot \frac{50}{100}\right) \cdot (80 + 200) = 112$.

翻译中…

In the second example, you can choose the first and second games. In this case, the expected value of winnings will be $\left(\frac{p_1}{100}\cdot \frac{p_2}{100}\right) \cdot (w_1 + w_2) = \left(\frac{100}{100}\cdot \frac{100}{100}\right) \cdot (1 + 1) = 2$.

翻译中…

In the third example, you can choose only the second game. In this case, the expected value of winnings will be $\frac{p_2}{100} \cdot w_2 = \frac{2}{100} \cdot 1000 = 20$.

翻译中…

样例

Input #1
3
80 80
70 100
50 200
Output #1
112.00000000
InputCopy OutputCopy
Input #2
2
100 1
100 1
Output #2
2.00000000
InputCopy OutputCopy
Input #3
4
1 100
2 1000
2 100
3 1
Output #3
20.00000000
InputCopy OutputCopy
Input #4
5
34 804
78 209
99 191
61 439
90 79
Output #4
395.20423800
InputCopy OutputCopy
题目信息
题号
2024F
时间限制
2 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。