結果

問題 No.108 トリプルカードコンプ
ユーザー ynyn
提出日時 2016-07-27 20:41:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 138 ms / 5,000 ms
コード長 791 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 86,016 KB
最終ジャッジ日時 2024-04-24 10:26:10
合計ジャッジ時間 3,587 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,224 KB
testcase_01 AC 38 ms
52,224 KB
testcase_02 AC 41 ms
53,248 KB
testcase_03 AC 43 ms
52,352 KB
testcase_04 AC 39 ms
52,480 KB
testcase_05 AC 39 ms
52,736 KB
testcase_06 AC 39 ms
52,224 KB
testcase_07 AC 138 ms
85,632 KB
testcase_08 AC 137 ms
85,632 KB
testcase_09 AC 137 ms
85,632 KB
testcase_10 AC 135 ms
85,768 KB
testcase_11 AC 136 ms
85,820 KB
testcase_12 AC 49 ms
61,952 KB
testcase_13 AC 86 ms
77,824 KB
testcase_14 AC 86 ms
77,696 KB
testcase_15 AC 84 ms
77,844 KB
testcase_16 AC 85 ms
77,824 KB
testcase_17 AC 86 ms
77,568 KB
testcase_18 AC 130 ms
85,260 KB
testcase_19 AC 127 ms
84,644 KB
testcase_20 AC 136 ms
86,016 KB
testcase_21 AC 132 ms
85,704 KB
testcase_22 AC 130 ms
84,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
arr = list(map(int,input().split()))

cnt = [0] * 4
for i in range(n):
    if arr[i] >= 3:
        cnt[3] += 1
    else:
        cnt[arr[i]] += 1

dp = [[[0 for i in range(n + 1)] for j in range(n + 1)] for k in range(n + 1)]

dp[0][0][0] = 0

for a in range(n + 1):
    for b in range(n + 1):
        for c in range(n + 1):
            if a + b + c == 0:
                continue

            dp[a][b][c] = n / (a + b + c)

            if a - 1 >= 0 and b + 1 <= n:
                dp[a][b][c] += a / (a + b + c) * dp[a - 1][b + 1][c]
            if b - 1 >= 0 and c + 1 <= n:
                dp[a][b][c] += b / (a + b + c) * dp[a][b - 1][c + 1]
            if c - 1 >= 0:
                dp[a][b][c] += c / (a + b + c) * dp[a][b][c - 1]

print(dp[cnt[0]][cnt[1]][cnt[2]])
0