結果

問題 No.133 カードゲーム
コンテスト
ユーザー IT_parsely
提出日時 2019-08-15 16:54:11
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 100 ms / 5,000 ms
コード長 551 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 631 ms
コンパイル使用メモリ 20,824 KB
実行使用メモリ 15,484 KB
最終ジャッジ日時 2026-04-08 02:34:21
合計ジャッジ時間 3,680 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import itertools

n = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
game_count = 0
game_A = 0

for cards_a in list(itertools.permutations(A, n)):
    for cards_b in list(itertools.permutations(B, n)):
        win_a = 0
        win_b = 0
        for card_a, card_b in zip(cards_a, cards_b):
            if card_a > card_b:
                win_a += 1
            elif card_b > card_a:
                win_b += 1

        game_count += 1
        if win_a > win_b:
            game_A += 1

print(game_A/game_count)
0