#include #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()); sort(B.begin(), B.end()); // すべての順列をA,B両方で生成し, // 互いの先頭の要素から比較し合う(順列生成(N!)は入れ子 int A_win = 0, btl_cnt = 0; int A_adv = 0, B_adv = 0; do { do { btl_cnt++; A_adv = 0, B_adv = 0; for (int i = 0; i < N; ++i) { if (A[i] > B[i]) A_adv++; else B_adv++; } if (A_adv > B_adv) A_win++; } while (next_permutation(A.begin(), A.end())); } while (next_permutation(B.begin(), B.end())); //cout << A_win << ' ' << btl_cnt << endl; cout << (double)A_win / (double)btl_cnt << endl; }