結果

問題 No.133 カードゲーム
ユーザー FromBooskaFromBooska
提出日時 2023-10-03 20:41:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 74 ms / 5,000 ms
コード長 836 bytes
コンパイル時間 333 ms
コンパイル使用メモリ 87,308 KB
実行使用メモリ 71,744 KB
最終ジャッジ日時 2023-10-03 20:41:44
合計ジャッジ時間 3,303 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,260 KB
testcase_01 AC 66 ms
71,548 KB
testcase_02 AC 67 ms
71,204 KB
testcase_03 AC 71 ms
71,420 KB
testcase_04 AC 67 ms
71,592 KB
testcase_05 AC 74 ms
71,368 KB
testcase_06 AC 68 ms
71,436 KB
testcase_07 AC 66 ms
71,528 KB
testcase_08 AC 66 ms
71,352 KB
testcase_09 AC 66 ms
71,740 KB
testcase_10 AC 65 ms
71,488 KB
testcase_11 AC 66 ms
71,560 KB
testcase_12 AC 67 ms
71,456 KB
testcase_13 AC 66 ms
71,560 KB
testcase_14 AC 67 ms
71,744 KB
testcase_15 AC 66 ms
71,656 KB
testcase_16 AC 66 ms
71,480 KB
testcase_17 AC 65 ms
71,608 KB
testcase_18 AC 67 ms
71,264 KB
testcase_19 AC 67 ms
71,488 KB
testcase_20 AC 70 ms
71,352 KB
testcase_21 AC 66 ms
71,660 KB
testcase_22 AC 67 ms
71,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 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