80分求助5,6WA
查看原帖
80分求助5,6WA
1120247
__asdfASDF12345楼主2024/6/16 15:16
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,z[20010],zz[20010],l[20010];
long long ans;
bool cmp(int a,int b)
{
	return a>b;
};
bool cmp1(int a,int b)
{
	return a<b;
};
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>l[i];
	for(int i=1;i<=m;i++)cin>>z[i];
	sort(z+1,z+1+m,cmp);
	sort(l+1,l+1+n,cmp);
	if(z[1]<l[1]||n>m)
	{
		cout<<"you died!"<<endl;
		system("pause");
		return 0;
	}
	sort(z+1,z+1+m,cmp1);
	sort(l+1,l+1+n,cmp1);
	int i=1,j=1;
	for(;i<=n;i++)
	{
		for(;j<=m;j++)
		{
			if(z[j]>=l[i])
			{
				ans+=z[j];
				break;
			}
		}
	}

	cout<<ans<<endl;
	return 0;
}

谁先让本蒟蒻AC,谁就多一个关注。 事先感谢所有帮忙的人,谢谢^_^

2024/6/16 15:16
加载中...