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
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<

 

你可能感兴趣的:(HDU 6435 CSGO 【脑洞】)