样例过了一Re剩下WA
查看原帖
样例过了一Re剩下WA
1028442
linruizhe111楼主2023/8/4 22:16
#include <bits/stdc++.h>
using namespace std;
int n,f=1,t;
double w[1005],ans,c[1005],y;
bool cmp(int p,int q){
	return p>q;
}
int main()
{
	cin>>n>>t;
	for(int i=1;i<=n;i++){
    	cin>>c[i]>>y;
		w[i]=y/c[i];
		}
	sort(w+1,w+n+1,cmp);
	while(t>0){
		if(c[f]>0)
			c[f]--,t-=1,ans+=w[f];
		else
		f++;
	}
	printf("%.2lf",ans);
 	return 0;//orz
}

样例过了一Re剩下WA

2023/8/4 22:16
加载中...