80分,求捞!!!
  • 板块学术版
  • 楼主_lxc__
  • 当前回复2
  • 已保存回复2
  • 发布时间2024/8/7 11:11
  • 上次更新2024/8/7 12:09:02
查看原帖
80分,求捞!!!
1408395
_lxc__楼主2024/8/7 11:11

为什么样例对了,可第一个点 RE 了

P2270P2270

#include<bits/stdc++.h>
using namespace std;
struct gold{
	double m,v;
	double jia;
}a[110];
bool cmp(gold x,gold y)
{
	return x.jia>y.jia;
}
int main()
{
	int n,t,pos=1;
	cin>>n>>t;
	double sum=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i].m>>a[i].v;
		a[i].jia=a[i].v/a[i].m;
	}
	sort(a+1,a+n+1,cmp);
	while(1)
	{
		if(t>=a[pos].m)
		{
			sum+=a[pos].v;
			t-=a[pos].m;
		}
		else
		{
			sum+=a[pos].v*(t/a[pos].m);
			break;
		}
		pos++;
	}
	cout<<fixed<<setprecision(2)<<sum;
	return 0;
}
2024/8/7 11:11
加载中...