結果
問題 | No.108 トリプルカードコンプ |
ユーザー | tktk_snsn |
提出日時 | 2020-06-03 22:33:32 |
言語 | Python3 (3.11.6 + numpy 1.26.0 + scipy 1.11.3) |
結果 |
TLE
|
実行時間 | - |
コード長 | 975 bytes |
コンパイル時間 | 148 ms |
コンパイル使用メモリ | 10,816 KB |
実行使用メモリ | 330,488 KB |
最終ジャッジ日時 | 2023-08-17 09:58:58 |
合計ジャッジ時間 | 7,156 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 18 ms
8,680 KB |
testcase_01 | AC | 18 ms
8,528 KB |
testcase_02 | AC | 23 ms
8,740 KB |
testcase_03 | AC | 19 ms
8,648 KB |
testcase_04 | AC | 19 ms
8,540 KB |
testcase_05 | AC | 19 ms
8,648 KB |
testcase_06 | AC | 18 ms
8,556 KB |
testcase_07 | TLE | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
ソースコード
from collections import Counter N = int(input()) A = list(map(int, input().split())) need = [max(3-a, 0) for a in A] cnt = Counter(need) # コンプまであと(1,2,3)枚必要なカード数がdp(a, b, c) # ここからdp(0,0,0)にするまでカードを買う回数の期待値 U = 3 * N + 1 dp = [[[0.0] * U for _ in range(U)] for _ in range(U)] for c in range(U): for b in range(U): if c + b > U: break for a in range(U): if c + b + a > U: break if a + b + c == 0: continue E = N p = 0 if a > 0: E += dp[a - 1][b][c] * a p += a if b > 0 and a < N: E += dp[a + 1][b - 1][c] * b p += b if c > 0 and b < N: E += dp[a][b + 1][c - 1] * c p += c dp[a][b][c] = E / p x = cnt[1] y = cnt[2] z = cnt[3] print(dp[x][y][z])