题目链接
http://acm.hdu.edu.cn/showproblem.php?pid=1052
#include<stdio.h>
#include<algorithm>//此处
using namespace std;
bool cmp(int a,int b)
{
return a>b;
}
int main()
{
int n,i,tj1,tj2,gw1,gw2,win,lose;
int a[1005],b[1005],sum;
while(scanf("%d",&n)==1&&n!=0)
{
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
for(i=0;i<n;i++)
{
scanf("%d",&b[i]);
}
sort(a,a+n,cmp); //排序
sort(b,b+n,cmp);
tj1=0,tj2=n-1;gw1=0,gw2=n-1;
win=0,lose=0;
for(i=0;i<n;i++)
{
if(a[tj1]>b[gw1])
//最快
{
win++;
tj1++;
gw1++;
}
else if(a[tj2]>b[gw2])
//最慢
{
win++;
tj2--;
gw2--;
}
else
{
if(a[tj2]<b[gw1])
//田忌最慢的马与齐王最快的马比较
{
lose++;
tj2--;
gw1++;
}
}
}
sum=(win-lose)*200;
printf("%d\n",sum);
}
return 0;
}