题目:Problem - 1052 (hdu.edu.cn)
#include<bits/stdc++.h>
using namespace std;
#define MXN 1000
bool cmp(int a,int b){
return a>b;
}
int main(){
int n,t[MXN],k[MXN];
while(scanf("%d",&n)){
if(n==0){
break;
}
for(int i=0;i<n;i++){
scanf("%d",&t[i]);
}
for(int i=0;i<n;i++){
scanf("%d",&k[i]);
}
sort(t,t+n,cmp);
sort(k,k+n,cmp);
int th=0,tt=n-1,kh=0,kk=n-1,w=0,l=0,d=0;
while(l+w+d<n){
if(t[th]>k[kh]){
th++;
kh++;
w++;
}
else if(t[th]<k[kh]){
tt--;
kh++;
l++;
}
else if(t[tt]<k[kk]){
tt--;
kh++;
l++;
}
else if(t[tt]>k[kk]){
tt--;
kk--;
w++;
}
else{
if(k[kh]>t[tt]){
l++;
}
else{
d++;
}
kh++;tt--;
}
}
printf("%d\n",(w-l)*200);
}
return 0;
}