2WA求助
查看原帖
2WA求助
1814868
OY666楼主2025/7/31 21:38
#include<bits/stdc++.h>
using namespace std;
struct wx
{
	long long p,t;
	float c;
}w[10005];
long long zt,n,ans;
int cmp(wx x,wx y)
{
	if(x.c==y.c) return x.t>y.t;
	else return x.c>y.c;
}
int main(){
	cin>>zt>>n;
	for(long long i=1;i<=n;i++)
	{
		cin>>w[i].p>>w[i].t;
		w[i].c=w[i].p*1.00/w[i].t;
	}
	sort(w+1,w+1+n,cmp);
	for(long long i=1;i<=n;i++)
	{
		int sum=zt/w[i].t;
		ans+=sum*w[i].p;
		zt=zt-sum*w[i].t;
	}
	cout<<ans;
	return 0;
}
2025/7/31 21:38
加载中...