我全哇了,请求大佬康康
查看原帖
我全哇了,请求大佬康康
88339
罗小黑小鱼楼主2021/8/24 19:41

全哇!

#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,T;
struct p{
	int m,v;
	double r;
}a[105];
double ans;
bool comp(const p &a,const p &b){
	return a.r>b.r;
}
signed main(){
	scanf("%lld%lld",&n,&T);
	for(int i=1;i<=n;i++){
		scanf("%lld%lld",&a[i].m,&a[i].v);
		a[i].r=double(a[i].v)/double(a[i].m);
	}
	sort(a+1,a+n+1,comp);
	int now=0,i=1;
	double ans=0;
	while(now+a[i].m<T){
		now+=a[i].m;
		ans+=a[i].v;
		i++;
	}
	ans+=(double(T-now)/double(a[i].m)*a[i].v);
	printf("%0.2llf",ans);
	return 0;
}
2021/8/24 19:41
加载中...