結果

問題 No.108 トリプルカードコンプ
ユーザー nisshy_280nisshy_280
提出日時 2022-12-14 15:41:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 410 ms / 5,000 ms
コード長 592 bytes
コンパイル時間 261 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 41,936 KB
最終ジャッジ日時 2024-04-25 19:59:36
合計ジャッジ時間 2,607 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,752 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 30 ms
10,752 KB
testcase_04 AC 30 ms
10,752 KB
testcase_05 AC 30 ms
10,752 KB
testcase_06 AC 29 ms
10,752 KB
testcase_07 AC 410 ms
41,936 KB
testcase_08 AC 39 ms
11,904 KB
testcase_09 AC 30 ms
10,752 KB
testcase_10 AC 30 ms
10,880 KB
testcase_11 AC 30 ms
10,752 KB
testcase_12 AC 30 ms
10,752 KB
testcase_13 AC 54 ms
13,480 KB
testcase_14 AC 39 ms
11,776 KB
testcase_15 AC 32 ms
11,136 KB
testcase_16 AC 45 ms
12,544 KB
testcase_17 AC 31 ms
10,880 KB
testcase_18 AC 311 ms
32,340 KB
testcase_19 AC 110 ms
18,752 KB
testcase_20 AC 61 ms
14,268 KB
testcase_21 AC 218 ms
32,380 KB
testcase_22 AC 37 ms
11,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache
@lru_cache(maxsize=100001)

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