main.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //reference: http://blog.csdn.net/u012766950/article/details/38319843
  2. #include <iostream>
  3. #include <vector>
  4. #include <algorithm>
  5. using namespace std;
  6. bool compare(int a, int b) {
  7. return a > b;
  8. }
  9. int main() {
  10. int n = 0, tmp = 0;
  11. vector<int> tian;
  12. vector<int> king;
  13. while (cin >> n&&n) {
  14. int count = 0;
  15. for (int i = 0; i < n; i++) {
  16. cin >> tmp;
  17. tian.push_back(tmp);
  18. }
  19. for (int i = 0; i < n; i++) {
  20. cin >> tmp;
  21. king.push_back(tmp);
  22. }
  23. sort(tian.begin(), tian.end());
  24. sort(king.begin(), king.end());
  25. for (; (tian.size());) {
  26. int size = tian.size();
  27. if (tian.at(size - 1) > king.at(size - 1)) {
  28. count++;
  29. tian.erase(tian.begin() + size - 1);
  30. king.erase(king.begin() + size - 1);
  31. }
  32. else if (tian.at(size - 1) < king.at(size - 1)) {
  33. count--;
  34. tian.erase(tian.begin());
  35. king.erase(king.begin() + size - 1);
  36. }
  37. else if (tian.at(0) > king.at(0)) {
  38. count++;
  39. tian.erase(tian.begin());
  40. king.erase(king.begin());
  41. }
  42. else if (tian.at(0) < king.at(0)) {
  43. count--;
  44. tian.erase(tian.begin());
  45. king.erase(king.begin() + size - 1);
  46. }
  47. else {
  48. if (tian.at(0) < king.at(size - 1))
  49. {
  50. count--;
  51. }
  52. tian.erase(tian.begin());
  53. king.erase(king.begin() + size - 1);
  54. }
  55. }
  56. cout << 200 * count << endl;
  57. tian.clear();
  58. king.clear();
  59. }
  60. return 0;
  61. }