結果

問題 No.133 カードゲーム
ユーザー Meso Meso
提出日時 2024-09-28 19:49:36
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 28 ms / 5,000 ms
コード長 490 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-09-28 19:49:40
合計ジャッジ時間 1,545 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

def fact(n):
    if n <= 1:
        return 1
    return n * fact(n-1)

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = 0
for i in itertools.permutations(a):
    for j in itertools.permutations(b):
        wa, wb = 0, 0
        for k in range(n):
            if i[k] > j[k]:
                wa += 1
            else:
                wb += 1
                
        if wa > wb:
            ans += 1

print(ans / fact(n) ** 2)
0