#include typedef int64_t ll; using namespace std; #define dump(x) cout << #x << " = " << (x) << endl; // #define dump(x) ; template inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } double solve(int n, vector a, vector b) { // next_permutaion の引数はソート済みである必要がある std::sort(a.begin(), a.end()); ll total = 0; ll a_win = 0; do { int a_up = 0; for (int i = 0; i < n; i++) { if (a.at(i) > b.at(i)) { a_up++; } if (a.at(i) < b.at(i)) { a_up--; } } if (a_up > 0) { a_win++; } total++; // next_permutaion の引数はソート済みである必要がある } while (next_permutation(a.begin(), a.end())); return static_cast(a_win) / static_cast(total); } // generated by oj-template v4.8.1 // (https://github.com/online-judge-tools/template-generator) int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; cin >> n; vector a(n), b(n); for (int i = 0; i < n; i++) { cin >> a.at(i); } for (int i = 0; i < n; i++) { cin >> b.at(i); } auto ans = solve(n, a, b); std::cout << ans << '\n'; return 0; }