結果

問題 No.133 カードゲーム
コンテスト
ユーザー FromBooska
提出日時 2023-10-03 20:41:40
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 30 ms / 5,000 ms
コード長 836 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 220 ms
コンパイル使用メモリ 84,736 KB
実行使用メモリ 52,224 KB
最終ジャッジ日時 2026-04-03 17:10:35
合計ジャッジ時間 1,933 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# N<=4なのですべての組合せを計算しても間に合うか
# AだけpermutationsすればBはpermutations必要ないだろう

from itertools import permutations

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A_all = []
for combo in permutations(range(N), N):
    temp = []
    for c in combo:
        temp.append(A[c])
    A_all.append(temp)

#print(A_all)

win = 0
lose = 0
draw = 0
for a in A_all:
    win_t = 0
    lose_t = 0
    draw_t = 0
    for i in range(N):
        if a[i] > B[i]:
            win_t += 1
        elif a[i] < B[i]:
            lose_t += 1
        elif a[i] == B[i]:
            draw_t += 1
    if win_t > lose_t:
        win += 1
    elif win_t < lose_t:
        lose += 1
    elif win_t == lose_t:
        draw += 1
ans = win/(win+lose+draw)
print(ans)
0