4

徐逸昊  •  1年前


include<bits/stdc++.h>

using namespace std; double s[10000]; bool cmp(int x,int y){

if(x>y)return y;
if(x<y)return x;

} int main() {

int x;
int su=0;
double n,m;
cin>>n>>m;
for(int i=1; i<=n; i++) {
	double a,b;
	cin>>a>>b;
	s[i]=b*1.0/a;
}
sort(s+1,s+1+n,cmp);
for(int i=1; i<=n; i++) {
	if(m-s[i]>=0) {
		su+=s[i];
		m-=s[i];
	} else {
		su+=m*s[i];
		break;
	}
}
cout<<su*1.0;
return 0;

}


评论: