結果

問題 No.155 生放送とBGM
ユーザー rpy3cpprpy3cpp
提出日時 2015-06-04 00:40:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,201 ms / 6,000 ms
コード長 943 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 265,380 KB
最終ジャッジ日時 2023-08-25 02:10:30
合計ジャッジ時間 7,520 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 835 ms
264,932 KB
testcase_01 AC 545 ms
219,592 KB
testcase_02 AC 2,201 ms
265,380 KB
testcase_03 AC 75 ms
71,068 KB
testcase_04 AC 147 ms
82,612 KB
testcase_05 AC 75 ms
71,644 KB
testcase_06 AC 156 ms
158,796 KB
testcase_07 AC 78 ms
75,496 KB
testcase_08 AC 77 ms
75,156 KB
testcase_09 AC 80 ms
75,232 KB
testcase_10 AC 75 ms
75,148 KB
testcase_11 AC 79 ms
75,304 KB
testcase_12 AC 81 ms
75,452 KB
testcase_13 AC 79 ms
75,504 KB
testcase_14 AC 678 ms
247,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import zip_longest as zl
from math import factorial as f
N,L=map(int,input().split())
L*=60
M=[]
for s in input().split():
  a,b = map(int,s.split(':'))
  M+=[a*60+b]

def G(M,dp,l,u):
  m=len(M)//2
  if m==0:
    t=max(len(dp[0])-M[0],0)
    return [sum(d[t:]) for d in dp]
  A=G(M[m:],*D(M[:m],dp,l[:],u[:]))
  B=G(M[:m],*D(M[m:],dp,l[:],u[:]))
  return [a+b for a,b in zl(A,B,fillvalue=0)]

def D(M,d0,l,u):
  dp=[d[:] for d in d0]
  for m in M:
    k=len(dp)-1
    if l[k]+m<L: dp.append([0]*L)
    for n in range(k,-1,-1):
      if l[n]>=L-m: continue
      nl=l[n]+m
      l[n+1]=min(l[n+1],nl)
      nu=min(u[n]+m,L-1)
      u[n+1]=max(u[n+1],nu)
      d=dp[n+1]
      for t, v in enumerate(dp[n][l[n]:min(u[n]+1,L-m)],nl):
        if v: d[t]+=v
  return dp,l,u

if sum(M)<=L:
  a=N
else:
  dp=[[0]*L]
  dp[0][0]=1
  l=[0]+[L]*N
  u=[0]*(N+1)
  g=G(M,dp,l,u)
  a=sum(v*f(n)*f(N-n) for n,v in enumerate(g,1))/f(N)
print(a)
0