結果

問題 No.108 トリプルカードコンプ
ユーザー ああいいああいい
提出日時 2022-03-31 21:34:41
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 548 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 162,048 KB
最終ジャッジ日時 2024-04-28 18:48:52
合計ジャッジ時間 7,378 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
54,656 KB
testcase_01 AC 46 ms
54,528 KB
testcase_02 AC 48 ms
55,168 KB
testcase_03 AC 48 ms
54,784 KB
testcase_04 AC 47 ms
54,656 KB
testcase_05 AC 50 ms
55,040 KB
testcase_06 AC 48 ms
55,424 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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))

import sys
sys.setrecursionlimit(10 ** 8)
from functools import lru_cache
@lru_cache(maxsize = 1000)
def calc(a,b,c):
    if a == 0 and b == 0 and c == 0:return 0
    u =a + b + c
    tmp = 0
    if a != 0:
        tmp += calc(a-1,b,c) * a
    if b != 0:
        tmp += calc(a+1,b-1,c) * b
    if c != 0:
        tmp += calc(a,b+1,c-1) * c
    tmp = (tmp + N) / u
    return tmp
a = 0
b = 0
c = 0
for i in A:
    if i == 0:c += 1
    elif i == 1:b += 1
    elif i == 2:a += 1
print(calc(a,b,c))
0