結果

問題 No.155 生放送とBGM
ユーザー mkawa2mkawa2
提出日時 2023-04-21 00:41:52
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,297 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 518,944 KB
最終ジャッジ日時 2024-04-23 18:17:40
合計ジャッジ時間 24,333 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 AC 5,403 ms
260,456 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
pDB = lambda *x: print(*x, end="\n", file=sys.stderr)
p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()

dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = (1 << 63)-1
# md = 10**9+7
md = 998244353

from copy import deepcopy

n,l=LI()

fac=[1]
for i in range(1,n+1):fac.append(fac[-1]*i)

l*=60
ss=SI().split()
ss=[int(s[0:2])*60+int(s[3:5]) for s in ss]
tot=sum(ss)

if tot<=l:
    print(n)
    exit()

dp=[[0]*l for _ in range(n+1)]
dp[0][0]=1

for si,s in enumerate(ss):
    for i in range(si+1,0,-1):
        for j in range(s,l):
            dp[i][j]+=dp[i-1][j-s]
# p2D(dp)

ans=0
for s in ss:
    cdp=deepcopy(dp)
    for i in range(n):
        for j in range(l):
            if i and j>=s:cdp[i][j]-=cdp[i-1][j-s]
            ans+=cdp[i][j]*fac[i]*fac[n-1-i]

ans/=fac[-1]
print(ans)
0