![](https://i-blog.csdnimg.cn/blog_migrate/b5b29a2dad41dc7833a3bacabb7e8963.png)
![](https://i-blog.csdnimg.cn/blog_migrate/456cc86865a55ef04146c9d7cb353ff9.png)
![](https://i-blog.csdnimg.cn/blog_migrate/1247e6e84ba105ae44373347b8c19fec.png)
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
//抄博友程序 经典
vector<int> a;
vector<int> b;
int main()
{
while(1)
{
int n;
cin>>n;
if(n==0)
{
return 0;
}
a.clear();
b.clear();
for(int i=0;i<n;i++)
{
int t;
cin>>t;
a.push_back(t);//田忌
}
for(int i=0;i<n;i++)
{
int t;
cin>>t;
b.push_back(t);//齐王
}
sort(a.begin(),a.end(),greater<int>());
sort(b.begin(),b.end(),greater<int>());
int l1=0, r1=n-1;
int l2=0, r2=n-1;
int jg=0;
while(l1<=r1)
{
if(a[l1]>b[l2])//田忌快马快于齐王的快马
{
jg=jg+200;
l1++;
l2++;
}else if(a[l1]<b[l2])//田忌的快马比齐王的快马慢
{
jg=jg-200;
r1--;//田忌的慢马与齐王的快马比
l2++;
}else
{
if(a[r1]>b[r2])//田忌的慢马快于齐王的慢马
{
jg=jg+200;
r1--;
r2--;
}else
{
//田忌的慢马与齐王的快马比
if(a[r1]<b[l2])//田忌的慢马比齐王的快马慢
{
jg=jg-200;
}
r1--;//田忌的慢马和齐王的快马等速
l2++;
}
}
}
cout<<jg<<endl;
}
return 0;
}