結果
| 問題 | No.133 カードゲーム | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-05-22 12:34:24 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 138 ms / 5,000 ms | 
| コード長 | 1,639 bytes | 
| コンパイル時間 | 243 ms | 
| コンパイル使用メモリ | 82,972 KB | 
| 実行使用メモリ | 89,872 KB | 
| 最終ジャッジ日時 | 2024-10-10 10:54:43 | 
| 合計ジャッジ時間 | 4,546 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 19 | 
ソースコード
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import copy, deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement, permutations
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
from operator import itemgetter
#import numpy as np #pypyでは使用不可
input = sys.stdin.readline
def int_input(): return int(input())
def int_map(): return map(int, input().split())
def int_list(): return list(int_map())
def int_row(N): return [int_input() for _ in range(N)]
def int_row_list(N): return [int_list() for _ in range(N)]
def str_input(): return input()[:-1]
def str_map(): return input().split()
def str_list(): return list(str_map())
def str_row(N): return [str_input() for _ in range(N)]
def str_row_list(N): return [list(str_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 10 ** 9 + 7
mod = 998244353
#メモリ消費を抑える時はグローバル空間に書く
def main():
    n = int_input()
    a = int_list()
    b = int_list()
    ans = 0
    for V in permutations(a):
        for W in permutations(b):
            a_win = 0; b_win = 0
            for i in range(n):
                if V[i] > W[i]:
                    a_win += 1
                if V[i] < W[i]:
                    b_win += 1
            if a_win > b_win:
                ans += 1
    print(ans / (factorial(n) ** 2))
if __name__ == '__main__':
    main()
            
            
            
        