#include #include #ifdef _DEBUG #include "debug.h" #endif //#define int ll #define float double #define FOR(i, s, e) for (int i = int(s); i < int(e); ++i) #define REP(i, e) FOR(i, 0, e) #define all(v) (v).begin(),(v).end() #define mkpr make_pair #define mktp make_tuple #define tv(tp, i) get<(i)>(tp) #define CLEAR(obj) obj = decltype(obj)() #define var auto #define OUT(type) type & #define IN(type) const type & #define self (*this) #define in : #define True true #define False false using namespace std; using int32 = int32_t; using ll = long long; using ull = unsigned long long; using vi = vector; using vvi = vector; using vl = vector; using vvl = vector; using vb = vector; using vvb = vector; using vc = vector; using vvc = vector; using vf = vector; using vvf = vector; using vd = vector; using vvd = vector; using str = string; using vs = vector; using pii = pair; using pll = pair; using pff = pair; using pdd = pair; using psl = pair; using tiii = tuple; using tlll = tuple; static const int MGN = 10; static const int ARYSZ_MAX = (int)1e7; static const ll LINF = LLONG_MAX/2; #ifdef int static const int INF = LINF; #else static const int INF = INT_MAX/2; #endif static double EPS = 1e-9; #define FASTCIN() cin.tie(0);ios::sync_with_stdio(false); #ifdef IMPORT_SAMPLE #define DEBUG_IMPORT(file) vs args(argv, argv+argc);str sample = make_sample(args, file);ifstream ifs(sample); cin.rdbuf(ifs.rdbuf()); #else #define DEBUG_IMPORT(file) #endif static inline int ord(char c) {return (int)c;} static inline char chr(int n) {return (char)n;} static inline bool DBLEQ(double a, double b) {return abs(a - b) < EPS;} static inline void EPR(str msg) {cerr << msg << endl;} static inline void AST(bool exp, str msg) {if(!exp){EPR(msg);} assert(exp);} static inline void TAST(bool exp, str msg) {if(!exp){EPR(msg);} while(!exp){}} void permutation(OUT(vvi) perm, IN(vi) A){ vi a = A; sort(a.begin(), a.end()); do { vi pt; for (int i : a) pt.push_back(i); perm.push_back(pt); } while (next_permutation(a.begin(), a.end())); } int32 main(int32 argc, char* argv[]) { FASTCIN(); DEBUG_IMPORT("sample-1"); int N; cin>>N; vi A(N); REP(i,N) cin>>A[i]; vi B(N); REP(i,N) cin>>B[i]; vvi permA; permutation(permA, A); vvi permB; permutation(permB, B); int all = permA.size() * permB.size(); //EPR("all: " + to_string(all)); int winA = 0; for (vi pa in permA) { for (vi pb in permB) { int wa = 0, wb = 0; REP(i,N) if (pa[i] > pb[i]) wa += 1; else if (pa[i] < pb[i]) wb += 1; if (wa > wb) winA += 1; } } //EPR("winA: " + to_string(winA)); double ans = winA/(double)all; //cout << ans << endl; printf("%.6lf", ans); return 0; }