题目描述
Problem Description
After a busy period, Little A and the Workaholic have successfully passed the review for the open competition. After the competition concluded smoothly, they received a salary of $m$ yuan. Now they face a tricky problem: how should they divide the salary?
The open competition consists of $n$ problems, where the $i$-th problem was set by $a_i$. If $a_i$ is $1$, it means the Workaholic set the problem; if $a_i$ is $2$, it means Little A set the problem.
According to the salary distribution rules in Guluo, the setter of a problem receives the entire salary for that problem. Each problem has a salary weight $b_i$, meaning the salary distribution ratio among the problems is $b_1 : b_2 : b_3 \ldots : b_{n-1} : b_n$.
Now, the Workaholic wants to know how much salary she will receive based on the above method.
Hint: It is recommended to understand the problem by referring to the sample explanation.
Input Format
The first line contains two integers $n$ and $m$, representing the number of problems in the competition and the total salary received by Little A and the Workaholic, respectively.
The next $n$ lines each contain two integers $a_i$ and $b_i$, representing the setter of the $i$-th problem and the salary weight of that problem, respectively.
Output Format
A single line containing a decimal number, representing the salary received by the Workaholic, rounded to three decimal places.
Sample Input and Output
Sample Input #1
4 1000
1 1
2 1
2 2
1 6
Sample Output #1
700.000
Sample Input #2
3 1000
1 3
1 30
2 300
Sample Output #2
99.099
Notes
Sample 1 Explanation
The competition has $4$ problems, and Little A and the Workaholic received a total of $1000$ yuan. The salary distribution ratio for the problems is $1 : 1 : 2 : 6$. Therefore, the salaries for the four problems are $1000 \times \frac{1}{1 + 1 + 2 + 6} = 100$ yuan, $1000 \times \frac{1}{1 + 1 + 2 + 6} = 100$ yuan, $1000 \times \frac{2}{1 + 1 + 2 + 6} = 200$ yuan, and $1000 \times \frac{6}{1 + 1 + 2 + 6} = 600$ yuan. The Workaholic set the first and fourth problems, so she receives $100 + 600 = 700$ yuan.
Data Size and Constraints
- For $20\%$ of the test cases, $a_i = 2$.
- For $100\%$ of the test cases, $2 \leq n \leq 10^6$, $1 \leq m \leq 10^9$, $1 \leq a_i \leq 2$, and $1 \leq b_i \leq 10^3$.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分