結果
| 問題 | No.133 カードゲーム | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-06-23 00:40:07 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 31 ms / 5,000 ms | 
| コード長 | 530 bytes | 
| コンパイル時間 | 91 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 10,752 KB | 
| 最終ジャッジ日時 | 2024-06-30 06:23:11 | 
| 合計ジャッジ時間 | 1,541 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 19 | 
ソースコード
from itertools import permutations
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
fact = 1
for i in range(1, n + 1):
    fact *= i
for P1 in permutations(range(n)):
    for P2 in permutations(range(n)):
        C = [0, 0]
        for i in range(n):
            p1i, p2i = P1[i], P2[i]
            if A[p1i] > B[p2i]:
                C[0] += 1
            elif A[p1i] < B[p2i]:
                C[1] += 1
        if C[0] > C[1]:
            ans += 1
ans /= fact * fact
print(ans)
            
            
            
        