如果己方最弱能干掉敌方最弱或者己方最强能干掉敌方最强就去干掉,肯定是最优的。如果都不行,那就用己方最弱去换掉敌方最强,注意判平局即可。
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define N 100010
inline int read(){
int x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
return x*f;
}
int n,a[N],b[N];
inline int solve(int *a,int *b){
int l1=1,r1=n,l2=1,r2=n,res=0;
while(l1<=r1){
if(a[l1]>b[l2]) res+=2,++l1,++l2;
else if(a[r1]>b[r2]) res+=2,--r1,--r2;
else res+=a[l1]==b[r2],++l1,--r2;
}return res;
}
int main(){
// freopen("a.in","r",stdin);
n=read();
for(int i=1;i<=n;++i) a[i]=read();
for(int i=1;i<=n;++i) b[i]=read();
sort(a+1,a+n+1);sort(b+1,b+n+1);
printf("%d %d\n",solve(a,b),n*2-solve(b,a));
return 0;
}