借鉴了了别人的思路:
http://www.cnblogs.com/xiaohongmao/p/4059863.html
#include<bits/stdc++.h>
using namespace std;
int a[1005],b[1005] ;
int main()
{int n,i,sum,l1,l2,r1,r2,flag;while(cin>>n){sum=0;if(n==0)break;for( i=1;i<=n;i++){cin>>a[i];}for( i=1;i<=n;i++){cin>>b[i];}sort(a+1,a+n+1);sort(b+1,b+1+n);if(a[1]>b[n]){printf("%d\n",n*200);continue;}else{l1=l2=1;r1=r2=n;while(r1>=l1&&r2>=l2){if(a[r1]>b[r2]){r1--;r2--;sum++;}else if(a[r1]==b[r2]){if(a[l1]<b[l2]){r2--;l1++;sum--;}else if(a[l1]>b[l2]){sum++;l1++;l2++;r1--;r2--;}else{if(b[r2]==a[l1]){break;}else if(b[r2]>a[l1]){l1++;r2--;sum--;}}}else{sum--;l1++;r2--;}}printf("%d\n",sum*200);}}return 0;
}