求助大佬救命,为什么会RE呀???
查看原帖
求助大佬救命,为什么会RE呀???
153653
徐大大楼主2021/4/3 14:12

求大佬帮我看看哪出问题了

第一个RE,第二个WA,其余都AC

#include<bits/stdc++.h>
using namespace std;
double d,e,f,g,t,ans1=0;
double ans2=0,c;
int a,n,b=1;
struct jinbi
{
	double m,v; 
	double v1;
}A1[110];
bool cmp(jinbi a,jinbi b)
{
	return a.v1>b.v1;
}
int main()
{
	cin>>n>>t;
	for(a=1;a<=n;a++)
	{
		cin>>A1[a].m>>A1[a].v;
		if(A1[a].m!=0)
		A1[a].v1=A1[a].v/A1[a].m;
	}
	sort(A1+1,A1+n,cmp);
	while(ans1<t)
	{
		if(A1[b].m<=t-ans1)
		{
			ans1+=A1[b].m;
			ans2+=A1[b].v;
			b++;
		}
		else
		{
			c=(t-ans1)*A1[b].v1;
			ans1=t;
			ans2+=c;
		}
	}
	cout<<setprecision(2)<<fixed<<ans2;
	return 0;
}
2021/4/3 14:12
加载中...