HDU 6435 CSGO 【脑洞】

 

Problem J. CSGO

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 248    Accepted Submission(s): 122


 

Problem Description

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)

S_{mw}+S_{sw} +\sum_{i=1}^{K}|X_{mw}[i]-X_{sw}[i]]|
Now you have to choose your best Main Weapon & Secondary Weapon and output the maximum evaluation.

 

Input

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

 

Output

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

题意:你有n把主武器,和m把副武器,每把武器有一个Sw值和k个Xw值。求选择一把主武器和一把副武器的

S_{mw}+S_{sw} +\sum_{i=1}^{K}|X_{mw}[i]-X_{sw}[i]]|最大

题解:不难发现  可以发现|X_{mw}-X_{sw}|=max(X_{mw}-X_{sw},X_{sw}-X_{mw})。然后因为k只有5可以枚举X_{mw}的正负,对如每个维度,主武器为正,副武器就为负,然后就能在O(32n)的复杂度求出答案。

 

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
typedef long long LL;

LL a[N][8],b[N][8],c[8],d[8];
int main()
{
    int TA,n,m,k;
    scanf("%d",&TA);
    while(TA--)
    {
        scanf("%d%d%d",&n,&m,&k);
        for(int i=1;i<=n;i++)
        {
            for(int j=0;j<=k;j++)
                scanf("%lld",&a[i][j]);
            swap(a[i][0],a[i][k]);
        }
         for(int i=1;i<=m;i++)
        {
            for(int j=0;j<=k;j++)
                scanf("%lld",&b[i][j]);
            swap(b[i][0],b[i][k]);
        }
        int tim=1<<k;
        LL ans=0;
        for(int i=0;i<tim;i++)
        {
            for(int j=0;j<k;j++)
            {
                if(i&(1<<j))
                    c[j]=1,d[j]=-1;
                else
                    c[j]=-1,d[j]=1;
            }
            LL ret1=-1e16,ret2=-1e16,tem;
            for(int j=1;j<=n;j++)
            {
                tem=a[j][k];
                for(int o=0;o<k;o++)
                    tem+=c[o]*a[j][o];
                ret1=max(ret1,tem);
            }

            for(int j=1;j<=m;j++)
            {
                tem=b[j][k];
                for(int o=0;o<k;o++)
                    tem+=d[o]*b[j][o];
                ret2=max(ret2,tem);
            }
            ans=max(ans,ret1+ret2);
        }
        printf("%lld\n",ans);
    }
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值