結果

問題 No.155 生放送とBGM
ユーザー rpy3cpprpy3cpp
提出日時 2015-06-04 00:25:10
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 3,353 ms / 6,000 ms
コード長 924 bytes
コンパイル時間 532 ms
コンパイル使用メモリ 87,072 KB
実行使用メモリ 265,784 KB
最終ジャッジ日時 2023-09-20 19:06:09
合計ジャッジ時間 10,195 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,176 ms
264,276 KB
testcase_01 AC 1,225 ms
260,672 KB
testcase_02 AC 3,353 ms
263,524 KB
testcase_03 AC 74 ms
71,656 KB
testcase_04 AC 181 ms
87,028 KB
testcase_05 AC 72 ms
71,344 KB
testcase_06 AC 160 ms
158,300 KB
testcase_07 AC 80 ms
75,500 KB
testcase_08 AC 76 ms
75,176 KB
testcase_09 AC 80 ms
75,452 KB
testcase_10 AC 76 ms
75,108 KB
testcase_11 AC 80 ms
75,732 KB
testcase_12 AC 84 ms
77,860 KB
testcase_13 AC 79 ms
75,508 KB
testcase_14 AC 1,013 ms
265,784 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)
      dp[n+1][nl:nu+1]=[a+b for a,b in zip(dp[n+1][nl:nu+1], dp[n][l[n]:u[n]+1])]
  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)
  a=sum(v*f(n)*f(N-n) for n,v in enumerate(G(M,dp,l,u),1))/f(N)
print(a)
0