#P2240. Alibaba's Fractional Treasure Heist
Alibaba's Fractional Treasure Heist
Alibaba's Fractional Treasure Heist
Alibaba has entered a treasure cave filled with piles of gold coins. There are \(N\) piles of coins. The \(i\)-th pile has a total weight \(m_i\) and a total value \(v_i\). Alibaba owns a backpack with a weight capacity of \(T\). However, he might not be able to take all the gold coins. Fortunately, the coins in each pile can be divided arbitrarily while maintaining the same unit price \(\left(\frac{v_i}{m_i}\right)\). Determine the maximum total value of coins Alibaba can take.
Note:
- \(1 \leq N \leq 100\)
- \(1 \leq m_i, v_i \leq 100\)
- \(T \leq 1000\)
inputFormat
The first line contains two integers \(N\) and \(T\), where \(N\) is the number of coin piles and \(T\) is the capacity of the backpack.
Each of the following \(N\) lines contains two integers \(m_i\) and \(v_i\), representing the total weight and total value of the \(i\)-th pile, respectively.
outputFormat
Output a single number, which is the maximum total value of coins that Alibaba can take. The answer should be printed with a precision of 6 decimal places.
sample
3 50
10 60
20 100
30 120
240.000000