http://bailian.openjudge.cn/practice/4110
贪心+排序
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <algorithm>
#define ll long long
using namespace std;
struct node
{
double v,w;
bool operator<(const node &x)const
{
return v/w>x.v/x.w;
}
}a[105];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n,w;
cin >> n >> w;
for(int i=0;i<n;i++)
cin >> a[i].v >> a[i].w;
sort(a,a+n);
double res=0;
for(int i=0;i<n;i++)
{
if(w>=a[i].w)
{
res+=a[i].v;
w-=a[i].w;
}
else
{
res+=w*a[i].v/a[i].w;
break;
}
}
printf("%.1f\n",res);
return 0;
}