結果

問題 No.108 トリプルカードコンプ
ユーザー nisshy_280nisshy_280
提出日時 2022-12-14 15:39:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 590 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 18,076 KB
最終ジャッジ日時 2024-04-25 19:58:41
合計ジャッジ時間 7,134 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,880 KB
testcase_01 AC 24 ms
10,752 KB
testcase_02 AC 24 ms
10,880 KB
testcase_03 AC 24 ms
10,752 KB
testcase_04 AC 27 ms
10,752 KB
testcase_05 AC 30 ms
10,752 KB
testcase_06 AC 30 ms
10,880 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 #

from functools import lru_cache
@lru_cache(maxsize=1000)

def solve(x,y,z):
    if x==n and y==n and z==n:
        return 0
    exp = n/(n-z)
    res = 0
    if x != n:
        res += (solve(x+1,y,z)+exp)*(n-x)/(n-z)
    if y != x:
        res += (solve(x,y+1,z)+exp)*(x-y)/(n-z)
    if z != y:
        res += (solve(x,y,z+1)+exp)*(y-z)/(n-z)
    return res

n = int(input())
A = list(map(int,input().split()))
count = [0,0,0]
for i in A:
    if i >= 1:
        count[0] += 1
    if i >= 2:
        count[1] += 1
    if i >= 3:
        count[2] += 1
print(solve(count[0],count[1],count[2]))
0