0
已解决
汤启恩
新手光能
新手光能
#include<bits/stdc++.h>
using namespace std;
struct tang{
int x,y;
}a[10001];
bool cmp(tang a,tang b){
return a.y>b.y;
}
int n,t;
double sum;
int main(){
cin>>n>>t;
for(int i=1;i<=n;i++)
cin>>a[i].x>>a[i].y;
sort(a+1,a+n+1,cmp);
for(int i=1;i<=n;i++){
if(t>=a[i].x){
sum+=a[i].y;
t-=a[i].x;
}
else{
sum+=a[i].y*1.0/a[i].x*t;
t=0;
break;
}
}
printf("%.2f",(int)(sum*100+0.5)/100.0);
return 0;
}
为啥零分???