全WA,e......
查看原帖
全WA,e......
818525
Steve2010楼主2023/1/30 09:44
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,m=20,ans=0,ld=0,rd=0;
int x[21]={0},y[21]={0},z[21]={0},w[21]={0};
int SF(int e[21],int f){
	ld=0;
	rd=0;
	sort(e,e+21);
	for(int m=20;m>=1;m--){
		if(e[m]!=0){
			if(ld>rd){
				rd+=e[m];
			}else{
				ld+=e[m];
			}
		}
	}
	if(ld>rd){
		return ld;
	}else{
		return rd;
	}
}
int main(){
	cin>>a>>b>>c>>d;
	for(int i=1;i<=a;i++){
		cin>>x[i];
	}
	for(int i=1;i<=b;i++){
		cin>>y[i];
	}
	for(int i=1;i<=c;i++){
		cin>>z[i];
	}
	for(int i=1;i<=d;i++){
		cin>>w[i];
	}
	cout<<SF(x,a)+SF(y,b)+SF(z,c)+SF(w,d);
	return 0;
}
2023/1/30 09:44
加载中...