#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int32_t n; cin >> n; vector> ais(n); for (auto i = 0; i < n; ++i) { int32_t a; cin >> a; ais[i] = {a, i}; } vector bs(n); for (auto &&b : bs) { cin >> b; } sort(ais.begin(), ais.end()); int32_t max_s = -1, ans = 0; do { int32_t s = 0; for (auto i = 0; i < n; ++i) { s += max(ais[i].first - bs[i], 0); } if (s == max_s) ++ans; else if (s > max_s) { max_s = s; ans = 1; } } while (next_permutation(ais.begin(), ais.end())); cout << ans << endl; return 0; }