結果
問題 | No.155 生放送とBGM |
ユーザー |
![]() |
提出日時 | 2023-04-21 00:56:58 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 5,305 ms / 6,000 ms |
コード長 | 1,384 bytes |
コンパイル時間 | 304 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 261,888 KB |
最終ジャッジ日時 | 2024-10-15 19:12:20 |
合計ジャッジ時間 | 28,411 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 |
ソースコード
import sys# sys.setrecursionlimit(200005)int1 = lambda x: int(x)-1pDB = 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+7md = 998244353from copy import deepcopyn, l = LI()fac = [1]for i in range(1, n+1): fac.append(fac[-1]*i)pp = [0]*nfor i in range(n): pp[i] = fac[i]*fac[n-1-i]/fac[-1]l *= 60ss = 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] = 1for 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 = 0for 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]*pp[i]print(f"{ans:.10f}")