类似田忌赛马,自己看了一天不知道怎么做,不知道怎么贪心,上网一搜都说大水题,原来是先看自己最弱的和对方最弱的能否战胜,不能的花看最强的和对方最强的,能否战胜,不能的话,用自己最弱的消耗掉对方最强的,在一场比赛中总分为2*n
设 甲 胜 x场 平y场 输z场
乙 输 x场 平y场 赢z场
x+y+z=n;
2*x+y+y+2*z=2*(x+y+z)=z*n;
#include<iostream>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int n,aa[100005],bb[100005];
int cal(int a[],int b[])
{
int sum=0;
int st1=1,ed1=n,st2=1,ed2=n;
while(st1<=ed1&&st2<=ed2)
{//cout<<st1<<" "<<ed1<<" "<<st2<<" "<<ed2<<" "<<sum<<endl;
if(a[st1]>b[st2])
{
sum+=2;
st1++;
st2++;
}
else
{
if(a[ed1]>b[ed2])
{
sum+=2;
ed1--;
ed2--;
}
else
{
if(a[st1]==b[ed2])
sum+=1;
st1++;
ed2--;
}
}
}
return sum;
}
int main()
{
int i;
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d",&aa[i]);
for(i=1;i<=n;i++)
scanf("%d",&bb[i]);
sort(aa+1,aa+1+n);
sort(bb+1,bb+1+n);
cout<<cal(aa,bb)<<" ";
cout<<2*n-cal(bb,aa)<<endl;
}