結果

問題 No.108 トリプルカードコンプ
ユーザー rlangevinrlangevin
提出日時 2023-10-29 01:20:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 91 ms / 5,000 ms
コード長 480 bytes
コンパイル時間 797 ms
コンパイル使用メモリ 81,848 KB
実行使用メモリ 85,836 KB
最終ジャッジ日時 2023-10-29 01:20:12
合計ジャッジ時間 3,473 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,584 KB
testcase_01 AC 37 ms
53,588 KB
testcase_02 AC 37 ms
53,580 KB
testcase_03 AC 38 ms
53,584 KB
testcase_04 AC 38 ms
53,584 KB
testcase_05 AC 38 ms
53,580 KB
testcase_06 AC 38 ms
53,580 KB
testcase_07 AC 91 ms
85,832 KB
testcase_08 AC 90 ms
85,836 KB
testcase_09 AC 91 ms
85,832 KB
testcase_10 AC 91 ms
85,828 KB
testcase_11 AC 90 ms
85,828 KB
testcase_12 AC 38 ms
53,588 KB
testcase_13 AC 62 ms
68,772 KB
testcase_14 AC 60 ms
68,772 KB
testcase_15 AC 61 ms
68,772 KB
testcase_16 AC 62 ms
68,772 KB
testcase_17 AC 60 ms
68,772 KB
testcase_18 AC 86 ms
84,768 KB
testcase_19 AC 86 ms
84,384 KB
testcase_20 AC 89 ms
85,648 KB
testcase_21 AC 90 ms
85,652 KB
testcase_22 AC 86 ms
84,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
X = [0] * 4
for a in A:
    X[min(a, 3)] += 1
    
dp = [[[0] * (N + 5) for i in range(N + 5)] for _ in range(N + 5)]
for n in range(1, N + 1):
    for z in range(n, -1, -1):
        for y in range(n - z, -1, -1):
            x = n - y - z
            s = x + y + z
            dp[x][y][z] = dp[x-1][y+1][z] * x + dp[x][y-1][z+1] * y + dp[x][y][z-1] * z + N
            dp[x][y][z] /= s
            
print(dp[X[0]][X[1]][X[2]])
0