#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
struct SCoin
{
int m, v;
}coin[101];
int N, T, t;
double V;
bool myCompare(const SCoin& first, const SCoin& second)
{
return first.v * second.m > second.v * first.m;
}
int main()
{
cin >> N >> T;
for (int i = 0; i < N; i++)
cin >> coin[i].m >> coin[i].v;
sort(coin, coin + N, myCompare);
for (int i = 0; i < N; i++)
{
if (T >= t + coin[i].m)
{
V += coin[i].v;
t += coin[i].m;
}
else
{
V += (T - t) * (coin[i].v * 1.0) / (coin[i].m * 1.0);
break;
}
}
cout << fixed << setprecision(2) << V;
return 0;
}
洛谷P2240 【深基12.例1】部分背包问题进阶解法
最新推荐文章于 2022-11-02 21:05:04 发布