当前位置: 首页 > 工具软件 > node-csgo > 使用案例 >

HDU 6435 Problem J. CSGO

聂迪
2023-12-01

题目传送门
代码:

#include<bits/stdc++.h>
using namespace std;

typedef long long LL;
const int maxn=100000+100;

struct Node{
	
	int s;
	int x[5];
}a[maxn],b[maxn];

LL ma[35],mb[35];

int main(){
	
	int T;
	scanf("%d",&T);
	while(T--){
		
		int n,m,k;
		scanf("%d%d%d",&n,&m,&k);
		for(int i=1;i<=n;i++){
			
			scanf("%d",&a[i].s);
			for(int j=0;j<k;j++) scanf("%d",&a[i].x[j]);
		}
		for(int i=1;i<=m;i++){
			
			scanf("%d",&b[i].s);
			for(int j=0;j<k;j++) scanf("%d",&b[i].x[j]);
		}
		int cnt=1;
		int p=k;
		while(p--) cnt*=2;
		for(int i=0;i<cnt;i++) ma[i]=mb[i]=-1e18;
		for(int i=0;i<cnt;i++){
			
			for(int j=1;j<=n;j++){
				
				LL sum=a[j].s;
				for(int t=0;t<k;t++){
					
					if((i>>t)&1) sum+=a[j].x[t];
					else sum-=a[j].x[t];
				}
				ma[i]=max(ma[i],sum);
			}
		}
		for(int i=0;i<cnt;i++){
			
			for(int j=1;j<=m;j++){
				
				LL sum=b[j].s;
				for(int t=0;t<k;t++){
					
					if((i>>t)&1) sum+=b[j].x[t];
					else sum-=b[j].x[t];
				}
				mb[i]=max(mb[i],sum);
			}
		}
		LL Max=0;
		for(int i=0;i<cnt;i++) Max=max(Max,ma[i]+mb[cnt-i-1]);
		printf("%lld\n",Max);
	}
} 
 类似资料:

相关阅读

相关文章

相关问答