結果

問題 No.155 生放送とBGM
ユーザー maspymaspy
提出日時 2020-04-19 01:07:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,033 bytes
コンパイル時間 556 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 51,180 KB
最終ジャッジ日時 2024-04-14 21:23:21
合計ジャッジ時間 10,372 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 670 ms
51,180 KB
testcase_01 AC 673 ms
50,796 KB
testcase_02 AC 681 ms
50,796 KB
testcase_03 AC 520 ms
44,392 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 654 ms
49,516 KB
testcase_07 AC 529 ms
44,016 KB
testcase_08 AC 518 ms
43,892 KB
testcase_09 AC 522 ms
44,400 KB
testcase_10 AC 525 ms
44,264 KB
testcase_11 AC 521 ms
44,264 KB
testcase_12 AC 520 ms
44,016 KB
testcase_13 AC 529 ms
44,396 KB
testcase_14 AC 626 ms
49,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

N, L = map(int, readline().split())
L *= 60

comb = np.zeros((60, 60), np.int64)
comb[0, 0] = 1
for n in range(1, 60):
    comb[n] += comb[n - 1]
    comb[n, 1:] += comb[n - 1, :-1]

def convert(s):
    minute, second = map(int, s.split(b':'))
    return 60 * minute + second


S = tuple(map(convert, read().split()))
full = sum(S)
if L >= full:
    print(N)
    exit()

dp = np.zeros((N + 1, L + 1), np.int64)
dp[0, 0] = 1


def add(dp, x):
    if x > L:
        return
    for n in range(N, 0, -1):
        dp[n, x:] += dp[n - 1, :-x]


def remove(dp, x):
    if x > L:
        return
    for n in range(1, N + 1):
        dp[n, x:] -= dp[n - 1, :-x]


for x in S:
    add(dp, x)

expected = 0
for x in S:
    if x > L:
        continue
    remove(dp, x)
    p = 0
    for n in range(N):
        p += dp[n, :L].sum() / comb[N - 1, n]
    p /= N
    expected += p
    add(dp, x)

print(expected)
0