Problem J. CSGO
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)
Total Submission(s): 272 Accepted Submission(s): 135
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)
Now you have to choose your best Main Weapon & Secondary Weapon and output the maximum evaluation.
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)
![](https://i-blog.csdnimg.cn/blog_migrate/e7551dc9a785ee5c0a133897967273a9.jpeg)
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
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.
Sample Input
2 2 2 1 0 233 0 666 0 123 0 456 2 2 1 100 0 1000 100 1000 100 100 0
Sample Output
543 2000
Source
由于| a[i]-b[i] | = max(a[i]-b[i],b[i]-a[i]) ,也就是说主武器和副武器的各个属性前面的符号是相反的,属性数量很少,可以枚举出所有的情况选出一个最优的就是答案。
1 #include<bits/stdc++.h> 2 using namespace std; 3 #define LL long long 4 #define mp make_pair 5 #define pb push_back 6 #define inf 0x7fffffffff 7 #define pii pair<int,int> 8 int x[200020][10]; 9 LL a[10]={1}; 10 int main() 11 { 12 int t,n,m,i,j,k; 13 cin>>t; 14 while(t--){ 15 scanf("%d%d%d",&n,&m,&k); 16 for(i=1;i<=n;++i) 17 for(j=0;j<k+1;++j) scanf("%d",&x[i][j]); 18 for(i=1;i<=m;++i) 19 for(j=0;j<k+1;++j) scanf("%d",&x[i+n][j]); 20 LL ans=-inf; 21 for(i=0;i<(1<<k);++i){ 22 for(j=0;j<k;++j)a[j+1]=(i&(1<<j))?1:-1; 23 LL mx1=-inf,mx2=-inf,tmp=0; 24 for(j=1;j<=n;++j){ 25 tmp=x[j][0]; 26 for(int o=1;o<k+1;++o){ 27 tmp+=a[o]*x[j][o]; 28 } 29 if(tmp>mx1)mx1=tmp; 30 } 31 for(j=n+1;j<=n+m;++j){ 32 tmp=x[j][0]; 33 for(int o=1;o<k+1;++o){ 34 tmp-=a[o]*x[j][o]; 35 } 36 if(tmp>mx2)mx2=tmp; 37 } 38 if(mx1+mx2>ans)ans=mx1+mx2; 39 } 40 cout<<ans<<endl; 41 } 42 return 0; 43 }