#include #include #include #include #include using namespace std; int main() { int N; cin >> N; vector a(N), b(N); for (int i = 0; i < N; i++) cin >> a[i]; for (int i = 0; i < N; i++) cin >> b[i]; sort(a.begin(), a.end()); int ans = 0; int maxScore = -1; do { int s = 0; for (int i = 0; i < N; i++) { s += max(0, a[i] - b[i]); } if (s > maxScore) { maxScore = s; ans = 0; cout << "max " << maxScore << endl; } if (s == maxScore) ans++; } while (next_permutation(a.begin(), a.end())); cout << ans << endl; }