1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
| #include <bits/stdc++.h>
#define int long long
#define ull unsigned long long #define MMST(x, y) memset(x, y, sizeof(x))
using namespace std;
const int INF = 0x3f3f3f3f;
int read() { char c; int num, f = 1; while (c = (char)getchar(), !isdigit(c)) if (c == '-') f = -1; num = (int)(c - '0'); while (c = (char)getchar(), isdigit(c)) num = num * 10 + (int)(c - '0'); return num * f; } void prt(int x) { if (x < 0) { putchar('-'); x = -x; } if (x > 9) prt(x / 10); putchar((char)(x % 10 + '0')); }
int n; int a[1003], b[1003];
void work() { while (n = read()) { for (int i = 1; i <= n; i++) a[i] = read(); for (int i = 1; i <= n; i++) b[i] = read(); sort(a + 1, a + 1 + n, [](int x, int y) { return x > y; }); sort(b + 1, b + 1 + n, [](int x, int y) { return x > y; }); int ji = 0, i = 1, j = 1, sum = 0, k = n, f = n; while (ji < n) { if (b[j] > a[i]) { sum -= 200; j++; k--; ji++; continue; } if (b[j] == a[i]) { if (b[f] < a[k]) { f--; k--; sum += 200; ji++; continue; } if (b[j] > a[k]) { sum -= 200; k--; j++; ji++; } else { k--; j++; ji++; } continue; } if (b[j] < a[i]) { sum += 200; j++; i++; ji++; continue; } } cout << sum << endl; } return; }
signed main() { int T = 1; for (int Case = 1; Case <= T; Case++) { work(); } return 0; }
|