結果

問題 No.108 トリプルカードコンプ
ユーザー tobusakanatobusakana
提出日時 2021-01-03 20:18:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 928 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 81,968 KB
実行使用メモリ 86,184 KB
最終ジャッジ日時 2024-04-21 15:34:17
合計ジャッジ時間 2,853 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,352 KB
testcase_01 AC 31 ms
51,840 KB
testcase_02 AC 33 ms
52,608 KB
testcase_03 AC 32 ms
52,352 KB
testcase_04 AC 31 ms
51,968 KB
testcase_05 AC 31 ms
51,968 KB
testcase_06 AC 31 ms
51,968 KB
testcase_07 WA -
testcase_08 AC 118 ms
85,632 KB
testcase_09 AC 122 ms
85,632 KB
testcase_10 AC 119 ms
85,700 KB
testcase_11 AC 123 ms
85,632 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# トリプルカードコンプ
N = int(input())
A = list(map(int,input().split()))

# dp[i][j][k] = 0枚持ってるカードがi種類、1枚のカードがj種類、2枚のカードがk種類ある
# 2枚持ってる状態からそのカードを当てると、管理対象から外れる

cnt = [0] * 11
for a in A:
  cnt[a] += 1
  
dp = [[[0] * (N + 2) for j in range(N + 2)] for i in range(N + 2)]
dp[0][0][0] = 0

for i in range(N + 1):
  for j in range(N + 1):
    for k in range(N + 1):
      if i == j == k:
        continue
      has = i + j + k
      dp[i][j][k] = N / has # いずれかの対象カードを引くための試行回数の期待値
      if k - 1 >= 0:
        dp[i][j][k] += dp[i][j][k - 1] * (k / has)
      if j - 1 >= 0:
        dp[i][j][k] += dp[i][j - 1][k + 1] * (j / has)
      if i - 1 >= 0:
        dp[i][j][k] += dp[i - 1][j + 1][k] * (i / has)
        
print(dp[cnt[0]][cnt[1]][cnt[2]])
0