贪心可过。原来浙江省选也不是那么难嘛。。
作者懒,粘的题解。此题类似于田忌赛马的策略,只要站在浙江队一方和站在对手一方进行考虑即可。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<set>
#include<ctime>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<deque>
#define inf 2000000000
#define ll long long
using namespace std;
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;
int a[100005],b[100005];
int ans1,ans2;
set<int> q;
int solve(int a[],int b[])
{
int l1=1,r1=n,l2=1,r2=n,ans=0;
while(l1<=r1&&l2<=r2)
{
if(a[l1]>b[l2]){ans+=2;l1++;l2++;}
else if(a[r1]>b[r2]){ans+=2;r1--;r2--;}
else {ans+=(a[l1]==b[r2]);l1++;r2--;}
}
return ans;
}
int main()
{
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
",solve(a,b),2*n-solve(b,a));
return 0;
}