bzoj1034 [ZJOI2008]泡泡堂BNB
SB贪心。
田忌赛马思想。// It is made by XZZ#include#include #define Fname "1034"using namespace std;#define rep(a,b,c) for(rg int a=b;a<=c;a++)#define drep(a,b,c) for(rg int a=b;a>=c;a--)#define erep(a,b) for(rg int a=fir[b];a;a=nxt[a])#define il inline#define rg register#define vd voidtypedef long long ll;il int gi(){ rg int x=0;rg bool flg=0;rg char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')flg=1;ch=getchar();} while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return flg?-x:x;}int n;int a[100010],b[100010];il int work(){ int l=1,r=n,L=1,R=n,ans=0; while(l<=r){ if(a[r]>b[R])ans+=2,--r,--R; else if(a[l]>b[L])ans+=2,++l,++L; else ans+=a[l]==b[R],++l,--R; }return ans;}int main(){ n=gi(); rep(i,1,n)a[i]=gi(); rep(i,1,n)b[i]=gi(); sort(a+1,a+1+n),sort(b+1,b+1+n); printf("%d ",work()); rep(i,1,n)swap(a[i],b[i]); printf("%d\n",n*2-work()); return 0;}