标签:style class blog code http tar
1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 using namespace std; 5 6 const int MAX=1010; 7 8 int tian[MAX],king[MAX]; 9 10 bool cmp(int a,int b){ 11 if(a>b) return true; 12 return false; 13 } 14 15 int main(){ 16 int n,cnt,unt; 17 while(scanf("%d",&n),n){ 18 cnt=unt=0; 19 for(int i=0;i<n;i++) 20 scanf("%d",&tian[i]); 21 for(int i=0;i<n;i++) 22 scanf("%d",&king[i]); 23 sort(tian,tian+n,cmp); 24 sort(king,king+n,cmp); 25 int front=0;int head=0; 26 int rear=n-1;int last=n-1; 27 while(front<=rear){ 28 if(tian[front]>king[head]){ 29 head++; front++; 30 cnt++; 31 } 32 else if(tian[front]<king[head]){ 33 unt++; 34 head++; rear--; 35 } 36 else { 37 if(tian[rear]>king[last]){ 38 cnt++; 39 rear--; last--; 40 } 41 else if(tian[rear]==king[head]){ 42 rear--; head++; 43 } 44 else{ 45 unt++; 46 rear--; head++; 47 } 48 } 49 } 50 printf("%d\n",(cnt-unt)*200); 51 } 52 return 0; 53 }
标签:style class blog code http tar
原文地址:http://www.cnblogs.com/jie-dcai/p/3791841.html