标签:style blog http color io for 2014 问题
input 3 92 83 71 95 92 74 3 92 83 70 92 91 60 output 0 200 |
#include"stdio.h"
#include"string.h"
#include"algorithm"
using namespace std;
#define N 1005
int cmp(int a,int b)
{
return a>b;
}
int main()
{
int i,n;
int a[N],b[N];
while(scanf("%d",&n),n)
{
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);
int c1,c2,a1,a2,b1,b2;
a1=b1=c1=c2=0;
a2=b2=n-1;
while(a1<=a2)
{
if(a[a1]>b[b1]) //田最快的马比王最快的马快
{
c1++;a1++;b1++;
}
else
{
if(a[a1]<b[b1]) //田最快的马比王最快的马慢
{
c2++;a2--;b1++;
}
else //田最快的马和王最快的马速度一样
{
if(a[a2]>b[b2]) //田最慢的马比王最慢的马快
{
c1++;a2--;b2--;
}
else
{
if(a[a2]<b[b1])
{
c2++;
}
a2--;b1++;
}
}
}
}
printf("%d\n",(c1-c2)*200);
}
return 0;
}
input 3 92 83 71 95 92 74 3 92 83 70 92 91 60 output 0 200 |
hdu 1052 Tian Ji -- The Horse Racing,布布扣,bubuko.com
hdu 1052 Tian Ji -- The Horse Racing
标签:style blog http color io for 2014 问题
原文地址:http://blog.csdn.net/u011721440/article/details/38260997