求大佬,全MLE!
查看原帖
求大佬,全MLE!
1490713
yikexinchen楼主2025/1/21 09:40
#include<bits/stdc++.h>
using namespace std;
struct problem{
	int n,pro[25],all=0;
}p[4];
int tim[1000];
int x[25],all2,q;
void time(problem a){
	int b=a.all/2;
	if(a.all%2!=0) b+=1;
	if(all2>=b){
		tim[q++]=all2;
		return;
	}
	for(int i1=0;i1<a.n;i1++){
		if(x[i1]!=1){
			all2+=a.pro[i1];
			x[i1]=1;
		}
		time(a);
		memset(x,0,sizeof(x));
		all2=0;
	}
	return;	
}
int main(){
	for(int i=0;i<4;i++){
		cin>>p[i].n;
	}
	for(int i=0;i<4;i++){
		for(int w=0;w<p[i].n;w++){
			cin>>p[i].pro[w];
			p[i].all+=p[i].pro[w];
		}
	}
	int ans=0;
	for(int i=0;i<4;i++){
		time(p[i]);
		sort(tim+0,tim+q);
		ans+=tim[0];
		memset(tim,0,sizeof(tim));
		q=0;all2=0;
	}
	cout<<ans;
	return 0;
}
2025/1/21 09:40
加载中...