結果

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

ソースコード

diff #

# https://qiita.com/drken/items/e77685614f3c6bf86f44
import itertools
import math

def main():
    n = int(input())
    a_list = list(map(int,input().split()))
    b_list = list(map(int,input().split()))

    cnt = 0
    for a_perm in itertools.permutations(a_list, n):
        for b_perm in itertools.permutations(b_list, n):
            a_win = 0
            for i in range(n):
                if a_perm[i]>b_perm[i]:
                    a_win += 1
            if a_win > n/2:
                cnt += 1
    # mathモジュールに階乗を返す関数factorial()
    print(cnt/math.factorial(n)/math.factorial(n))
if __name__ == '__main__':
    main()
0