#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int a[10], b[10]; vector vec; int main() { int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; vec.emplace_back(i); } int ans = 0, ans1 = 1; for (int i = 0; i < n; i++) { cin >> b[i]; ans += max(0, a[i] - b[i]); } while (next_permutation(vec.begin(), vec.end())) { int co = 0; for (int i = 0; i < n; i++) { co += max(0, a[vec[i]] - b[i]); } if (co > ans) { ans = co; ans1 = 1; } else if (co == ans) { ans1++; } } cout << ans1 << endl; }