杭电第十场 问题 J: CSGO

题目描述

You are playing CSGO.
There are n Main Weapons and m Secondary Weapons in CSGO. You can only choose one Main Weapon and one Secondary Weapon. For each weapon, it has a composite score S.
The higher the composite score of the weapon is, the better for you.
Also each weapon has K performance evaluations x[1], x[2], …, x[K].(range, firing rate, recoil, weight…)
So you shold consider the cooperation of your weapons, you want two weapons that have big difference in each performance, for example, AWP + CZ75 is a good choose, and so do AK47 + Desert Eagle.
All in all, you will evaluate your weapons by this formula.(MW for Main Weapon and SW for Secondary Weapon)

Now you have to choose your best Main Weapon & Secondary Weapon and output the maximum evaluation.

 

输入

Multiple query.
On the first line, there is a positive integer T, which describe the number of data. Next there are T groups of data.
for each group, the first line have three positive integers n, m, K.
then, the next n line will describe n Main Weapons, K+1 integers each line S, x[1], x[2], …, x[K]
then, the next m line will describe m Secondary Weapons, K+1 integers each line S, x[1], x[2], …, x[K]
There is a blank line before each groups of data.
T<=100, n<=100000, m<=100000, K<=5, 0<=S<=1e9, |x[i]|<=1e9, sum of (n+m)<=300000

 

输出

Your output should include T lines, for each line, output the maximum evaluation for the corresponding datum.

 

样例输入

2
2 2 1
0 233
0 666
0 123
0 456
2 2 1
100 0 1000 100 1000 100
100 0

 

样例输出

543
2000

你正在打cs,有n把主武器,m把副武器,没把武器的威力为s,除此,每把武器有k个性能指标,现在你要各选择一把武器,使得

公式的值最大。

公式的后半部分是一个曼哈顿距离,所以,我们尝试去枚举所有状态,对于每把武器,我们只有取和不取的状态,对于每种状态,武器性能的贡献值有加和减两种状态,即k纬,因为k很小,所以位运算枚举即可。

#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct node
{
    int s;
    int x[6];
}Main[100050],Second[100050];
int main()
{
    int t,n,m,k;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d %d %d",&n,&m,&k);
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&Main[i].s);
            for(int j=1;j<=k;j++)
            {
                scanf("%d",&Main[i].x[j]);
            }
        }
        for(int i=1;i<=m;i++)
        {
            scanf("%d",&Second[i].s);
            for(int j=1;j<=k;j++)
            {
                scanf("%d",&Second[i].x[j]);
            }
        }
        int tt=(1<<k);
        ll maxx[35];
        for(int i=0;i<=34;i++)
        {
            maxx[i]=-1e17;
        }
        for(int i=0;i<tt;i++)
        {
            for(int j=1;j<=n;j++)
            {
                ll sum=Main[j].s;
                for(int p=1;p<=k;p++)
                {
                    if(i>>(p-1)&1)
                    {
                        sum+=Main[j].x[p];
                    }
                    else
                    {
                        sum-=Main[j].x[p];
                    }
                }
                maxx[i]=max(maxx[i],sum);
            }
        }
        ll mbxx[35];
        for(int i=0;i<=34;i++)
        {
            mbxx[i]=-1e17;
        }
        for(int i=0;i<tt;i++)
        {
            for(int j=1;j<=m;j++)
            {
                ll sum=Second[j].s;
                for(int p=1;p<=k;p++)
                {
                    if(i>>(p-1)&1)
                    {
                        sum-=Second[j].x[p];
                    }
                    else
                    {
                        sum+=Second[j].x[p];
                    }
                }
                mbxx[i]=max(mbxx[i],sum);
            }
        }
        ll ans=0;
        for(int i=0;i<tt;i++)
        {
            ans=max(ans,maxx[i]+mbxx[i]);
        }
        printf("%lld\n",ans);
    }
    return 0;
}

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值