P2240 [Deep Basics 12.Example 1] Fractional Knapsack Problem
Description
Alibaba walked into a treasure cave full of treasures. In the cave, there are $N(N \le 100)$ piles of gold coins. For the $i$-th pile, the total weight and total value are $m_i,v_i(1\le m_i,v_i \le 100)$. Alibaba has a knapsack with capacity $T(T \le 1000)$, but it may not be possible to pack all the gold coins. He wants to take away gold coins with as much total value as possible. All gold coins can be divided freely, and after dividing, the value-to-weight ratio (i.e., the unit price) stays the same. Find the maximum total value of gold coins that Alibaba can take away.
Input Format
The first line contains two integers $N, T$.
The next $N$ lines each contain two integers $m_i, v_i$.
Output Format
Output one real number as the answer, printed to two decimal places.
Explanation/Hint
Translated by ChatGPT 5