#include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define int long long #define double long double typedef vector VI; typedef pair pii; typedef vector VP; typedef vector VS; typedef priority_queue PQ; templatebool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } templatebool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } #define fore(i,a) for(auto &i:a) #define REP(i,n) for(int i=0;i, greater > q2; signed main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; VI A(N), B(N),c(N); REP(i, N)cin >> A[i]; REP(i, N)cin >> B[i]; int ans = 0, ma = -INF; REP(i, N)c[i] = i; do { int cnt = 0; REP(i, N) { cnt += max(0LL, A[c[i]] - B[i]); } if (ma < cnt) { ans = 1; ma = cnt; } else if (ma == cnt) { ans++; } } while (next_permutation(c.begin(), c.end())); cout << ans << endl; return 0; }