提交时间:2026-04-11 20:25:11
运行 ID: 436181
#include<bits/stdc++.h> using namespace std; struct hsg{ int w,v; double k; }a[10086]; bool cmp(hsg x,hsg y){ return x.k>y.k; } int main(){ int n,c; cin>>n>>c; for(int i=1;i<=n;i++){ cin>>a[i].w>>a[i].v; a[i].k=1.0*a[i].v/a[i].w; } sort(a+1,a+n+1,cmp); double s=0; int b=0; while(c>0){ b++; if(c>=a[b].w){ c=c-a[b].w; s=s+a[b].v; }else{ s+=c*a[b].k; c=0; } } cout<<fixed<<setprecision(1)<<s; return 0; }