题解
贪心策略:先从小到大排序,如果我方最弱的比敌方最弱的强分数+2,如果我方最强的比敌方最强的要强分数+2。否则既然都打不过,我就让什么用都不起的我方最弱跟敌方最强比。碰巧一样厉害分数+1。
代码
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cctype>
#define N 100050
using namespace std;
int a[N],b[N],n;
inline int read()
{
int ret=0;char ch=getchar();
for (;!isdigit(ch);ch=getchar());
for (;isdigit(ch);ch=getchar()) ret=ret*10+ch-'0';
return ret;
}
void readln()
{
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+1+n),sort(b+1,b+1+n);
}
int query(int a[],int b[])
{
int l1=1,r1=n,l2=1,r2=n,ret=0;
while(l1<=r1&&l2<=r2)
{
if (a[l1]>b[l2]) ret+=2,l1++,l2++;
else
if (a[r1]>b[r2]) ret+=2,r1--,r2--;
else {if (a[l1]==b[r2]) ret+=1;l1++,r2--;}
}
return ret;
}
int main()
{
readln();
printf("%d %d\n",query(a,b),2*n-query(b,a));
return 0;
}