結果

問題 No.108 トリプルカードコンプ
ユーザー ynyn
提出日時 2016-07-27 20:41:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 178 ms / 5,000 ms
コード長 791 bytes
コンパイル時間 474 ms
コンパイル使用メモリ 86,752 KB
実行使用メモリ 93,616 KB
最終ジャッジ日時 2023-08-06 14:56:36
合計ジャッジ時間 4,575 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,108 KB
testcase_01 AC 73 ms
71,272 KB
testcase_02 AC 77 ms
71,444 KB
testcase_03 AC 75 ms
70,916 KB
testcase_04 AC 74 ms
71,288 KB
testcase_05 AC 74 ms
71,268 KB
testcase_06 AC 74 ms
71,116 KB
testcase_07 AC 178 ms
92,896 KB
testcase_08 AC 175 ms
92,524 KB
testcase_09 AC 178 ms
92,908 KB
testcase_10 AC 176 ms
92,752 KB
testcase_11 AC 175 ms
92,640 KB
testcase_12 AC 84 ms
76,288 KB
testcase_13 AC 116 ms
78,772 KB
testcase_14 AC 115 ms
78,516 KB
testcase_15 AC 115 ms
78,444 KB
testcase_16 AC 120 ms
78,788 KB
testcase_17 AC 117 ms
78,172 KB
testcase_18 AC 162 ms
85,380 KB
testcase_19 AC 158 ms
85,396 KB
testcase_20 AC 174 ms
93,504 KB
testcase_21 AC 173 ms
93,616 KB
testcase_22 AC 162 ms
85,228 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