标签:
Description
Input
Output
Sample Input
Sample Output
1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 #define maxn 1000+5 5 int tian[maxn]; 6 int king[maxn]; 7 int main() 8 { 9 int n; 10 while (cin >> n) 11 { 12 int af, ae; 13 int bf, be; 14 int ans = 0; 15 if (n == 0) 16 break; 17 memset(tian, 0, sizeof(tian)); 18 memset(king, 0, sizeof(king)); 19 for (int i = 0; i < n; i++) 20 { 21 cin >> tian[i]; 22 } 23 for (int i = 0; i < n; i++) 24 { 25 cin >> king[i]; 26 } 27 sort(tian, tian + n); 28 sort(king, king + n); 29 af = 0; ae = n - 1; 30 bf = 0; be = n - 1; 31 while (af <=ae&&bf <=be) 32 { 33 if (tian[af] > king[bf]) 34 { 35 ans += 200; 36 af++; bf++; 37 } 38 else if (tian[af] < king[bf]) 39 { 40 ans -= 200; 41 af++; 42 be--; 43 } 44 else 45 { 46 if (tian[ae]>king[be]) 47 { 48 ans += 200; 49 be--; 50 ae--; 51 } 52 else if (tian[ae] < king[be]) 53 { 54 ans -= 200; 55 af++; 56 be--; 57 } 58 else 59 { 60 if (tian[af]<king[be]) 61 { 62 ans -= 200; 63 af++; 64 be--; 65 } 66 else if (tian[af] == king[be]) 67 break; 68 } 69 } 70 } 71 cout << ans << endl; 72 } 73 return 0; 74 }
标签:
原文地址:http://www.cnblogs.com/Lynn0814/p/4726473.html