题解
1.经过样例证明,双方的交换策略一定是自己最小值去换对面最大值
2.双方交换的最大值一定局限在双方各自初始最大值之间,最小值也是
code
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ll t;
cin>>t;
while(t--)
{
ll n,m,k;
cin>>n>>m>>k;
ll suma=0,sumb=0,min_a=2e9,min_b=2e9,max_a=0,max_b=0;
ll x;
for(ll i=1;i<=n;i++)
{
cin>>x;
suma+=x;
max_a=max(max_a,x);
min_a=min(min_a,x);
}
for(ll i=1;i<=m;i++)
{
cin>>x;
sumb+=x;
max_b=max(max_b,x);
min_b=min(min_b,x);
}
if(k&1ll)
{
cout<<suma+max(0ll,max_b-min_a)<<endl;
}
else
{
cout<<suma+max(0ll,max_b-min_a)-max(max_a,max_b)+min(min_a,min_b)<<endl;
}
}
return 0;
}
标签:2e9,min,max,ll,long,Game,最大值,Jellyfish
From: https://www.cnblogs.com/pure4knowledge/p/18193771