結果
| 問題 | No.108 トリプルカードコンプ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-02-02 17:01:35 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 119 ms / 5,000 ms |
| + 801µs | |
| コード長 | 761 bytes |
| 記録 | |
| コンパイル時間 | 239 ms |
| コンパイル使用メモリ | 96,084 KB |
| 実行使用メモリ | 89,344 KB |
| 最終ジャッジ日時 | 2026-07-25 09:58:07 |
| 合計ジャッジ時間 | 3,300 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
N = int(input())
*A, = map(int, input().split())
c0, c1, c2 = A.count(0), A.count(1), A.count(2)
DP = [[[None]*(c0+c1+c2-(i+j)+1) for j in range(c1+c0-i+1)]
for i in range(c0+1)]
def solve(a, b, c):
if a == b == c == 0:
return 0
if DP[a][b][c] is not None:
return DP[a][b][c]
ans = 0
if a > 0:
ans += a * solve(a-1, b+1, c)
if b > 0:
ans += b * solve(a, b-1, c+1)
if c > 0:
ans += c * solve(a, b, c-1)
DP[a][b][c] = (ans + N) / (a+b+c)
return DP[a][b][c]
print(solve(c0, c1, c2))
if __name__ == '__main__':
main()