// #include #include // cout, endl, cin #include // setprecision #include // string, to_string, stoi #include // vector #include // min, max, swap, sort, reverse, lower_bound, upper_bound #include // pair, make_pair #include // tuple, make_tuple #include // int64_t, int*_t #include // printf #include // map #include // queue, priority_queue #include // set #include // stack #include // deque #include // unordered_map #include // unordered_set #include // bitset #include // isupper, islower, isdigit, toupper, tolower #include // pow // #define int long long // loop #define FOR(i, a, b) for (int i = (a); i < (b); i++) // a ~ b-1 (ascending) #define REP(i, n) FOR(i, 0, n) // 0 ~ n-1 #define NREP(i, n) FOR(i, 1, n + 1) // 1 ~ n #define RFOR(i, a, b) for (int i = (a); i >= (b); i--) // a ~ b (descending) #define RREP(i, n) RFOR(i, n, 0) // n ~ 0 #define RNREP(i, n) RFOR(i, n, 1) // n ~ 1 // container operation #define all(v) v.begin(), v.end() #define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++) #define ASORT(c) std::sort((c).begin(), (c).end()) #define DSORT(c) std::sort((c).begin(), (c).end(), std::greater()) #define SIZE(x) ((int)(x).size()) // union of two containers template void container_union(T &c1, T &c2, T &c3) { std::vector vec; std::set_union(c1.begin(), c1.end(), c2.begin(), c2.end(), std::back_inserter(vec)); T tmp(vec.begin(), vec.end()); c3 = tmp; } // chmax, chmin template bool chmax(T &a, const T& b) { if (a < b) { a = b; // aをbで更新 return true; } return false; } template bool chmin(T &a, const T& b) { if (a > b) { a = b; // aをbで更新 return true; } return false; } // grid-search std::vector dx = {1, -1, 0, 0}; std::vector dy = {0, 0, 1, -1}; // debug #define check(x) std::cout << #x << " = " << x << '\n' // print #define cout(x) std::cout << x << '\n' // type alias using VI = std::vector; using VII = std::vector; using VB = std::vector; using VBB = std::vector; using VS = std::vector; using PII = std::pair; // yes/no std::string yes = "Yes"; std::string no = "No"; std::string YES = "YES"; std::string NO = "NO"; void solve(); signed main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout << std::fixed << std::setprecision(10); solve(); return 0; } void solve() { int n; std::cin >> n; VI a(n), b(n), pa(n), pb(n); REP(i, n) { std::cin >> a.at(i); pa.at(i) = i; } REP(i, n) { std::cin >> b.at(i); pb.at(i) = i; } int wa = 0; int g = 0; do { do { int ca = 0; int cb = 0; REP(i, n) { if (a.at(pa.at(i)) > b.at(pb.at(i))) { ca++; } else if (b.at(pb.at(i)) > a.at(pa.at(i))) { cb++; } } if (ca > cb) { wa++; } g++; } while (std::next_permutation(all(pb))); } while (std::next_permutation(all(pa))); cout(1. * wa / g); }