結果

問題 No.133 カードゲーム
ユーザー 後藤駿輔後藤駿輔
提出日時 2021-04-19 22:31:56
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 653 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 10,592 KB
実行使用メモリ 8,380 KB
最終ジャッジ日時 2023-09-17 08:31:04
合計ジャッジ時間 1,622 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,172 KB
testcase_01 AC 16 ms
8,240 KB
testcase_02 AC 16 ms
8,200 KB
testcase_03 AC 17 ms
8,320 KB
testcase_04 AC 16 ms
8,216 KB
testcase_05 AC 17 ms
8,212 KB
testcase_06 AC 17 ms
8,212 KB
testcase_07 AC 16 ms
8,332 KB
testcase_08 AC 16 ms
8,196 KB
testcase_09 AC 16 ms
8,184 KB
testcase_10 AC 16 ms
8,212 KB
testcase_11 AC 17 ms
8,148 KB
testcase_12 AC 17 ms
8,280 KB
testcase_13 AC 16 ms
8,252 KB
testcase_14 AC 16 ms
8,320 KB
testcase_15 AC 16 ms
8,260 KB
testcase_16 AC 17 ms
8,216 KB
testcase_17 AC 16 ms
8,344 KB
testcase_18 AC 16 ms
8,356 KB
testcase_19 AC 16 ms
8,380 KB
testcase_20 AC 17 ms
8,352 KB
testcase_21 AC 16 ms
8,144 KB
testcase_22 AC 16 ms
8,212 KB
権限があれば一括ダウンロードができます

ソースコード

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