結果

問題 No.108 トリプルカードコンプ
ユーザー takakintakakin
提出日時 2020-07-09 23:43:14
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 504 ms / 5,000 ms
コード長 645 bytes
コンパイル時間 107 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 25,088 KB
最終ジャッジ日時 2024-04-17 05:47:18
合計ジャッジ時間 6,253 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,752 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 29 ms
10,880 KB
testcase_03 AC 30 ms
10,880 KB
testcase_04 AC 30 ms
10,624 KB
testcase_05 AC 30 ms
10,752 KB
testcase_06 AC 30 ms
10,752 KB
testcase_07 AC 494 ms
25,088 KB
testcase_08 AC 504 ms
24,960 KB
testcase_09 AC 479 ms
25,088 KB
testcase_10 AC 473 ms
24,960 KB
testcase_11 AC 491 ms
24,960 KB
testcase_12 AC 31 ms
10,752 KB
testcase_13 AC 80 ms
12,288 KB
testcase_14 AC 76 ms
12,288 KB
testcase_15 AC 77 ms
12,288 KB
testcase_16 AC 80 ms
12,416 KB
testcase_17 AC 71 ms
11,904 KB
testcase_18 AC 429 ms
23,424 KB
testcase_19 AC 398 ms
22,656 KB
testcase_20 AC 448 ms
24,832 KB
testcase_21 AC 461 ms
24,704 KB
testcase_22 AC 450 ms
23,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
A=[int(i) for i in input().split()]
DP=[[[0]*(n+1) for i in range(n+1)] for j in range(n+1)]
for i in range(n+1):
  for j in range(n+1):
    for k in range(n+1):
      if i==0 and j==0 and k==0:
        continue
      elif i+j+k>n:
        continue  
      else:
        DP[i][j][k]=1
        if i>0:
          DP[i][j][k]+=i/n*DP[i-1][j+1][k]
        if j>0:
          DP[i][j][k]+=j/n*DP[i][j-1][k+1]
        if k>0:
          DP[i][j][k]+=k/n*DP[i][j][k-1]
        DP[i][j][k]*=n/(i+j+k)
C=[0]*3
for a in A:
  if a<3:
    C[a]+=1
c1,c2,c3=C
print(DP[c1][c2][c3])
        
0