結果
問題 |
No.108 トリプルカードコンプ
|
ユーザー |
![]() |
提出日時 | 2022-12-14 15:39:38 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 590 bytes |
コンパイル時間 | 217 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 16,256 KB |
最終ジャッジ日時 | 2024-11-08 07:41:37 |
合計ジャッジ時間 | 7,138 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 4 TLE * 1 -- * 15 |
ソースコード
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]))