Upload code_segments/segment_336.txt with huggingface_hub
Browse files
code_segments/segment_336.txt
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
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.
|
2 |
+
|
3 |
+
The conditions in this casino are as follows:
|
4 |
+
|
5 |
+
* 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).
|
6 |
+
|
7 |
+
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.
|
8 |
+
|
9 |
+
In this case, if you choose to play the games with indices $i_1 < i_2 < \ldots < 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}$.
|
10 |
+
|
11 |
+
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)$.
|
12 |
+
|
13 |
+
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$.
|
14 |
+
|
15 |
+
Your task is to find the maximum expected value of winnings that can be obtained by choosing some set of games in the casino.
|
16 |
+
|
17 |
+
The first line contains a single integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the number of games offered to play.
|
18 |
+
|
19 |
+
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.
|
20 |
+
|
21 |
+
Output a single number — the maximum expected value of winnings in the casino that can be obtained by choosing some subset of games.
|
22 |
+
|
23 |
+
Your answer will be accepted if the relative or absolute error does not exceed $10^{-6}$. Formally, if
|