結果

問題 No.155 生放送とBGM
ユーザー maspymaspy
提出日時 2020-04-19 01:10:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 650 ms / 6,000 ms
コード長 1,003 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 48,772 KB
最終ジャッジ日時 2024-04-14 21:23:49
合計ジャッジ時間 10,216 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 639 ms
48,704 KB
testcase_01 AC 638 ms
48,772 KB
testcase_02 AC 650 ms
48,644 KB
testcase_03 AC 506 ms
43,628 KB
testcase_04 AC 514 ms
43,884 KB
testcase_05 AC 507 ms
43,764 KB
testcase_06 AC 628 ms
47,492 KB
testcase_07 AC 506 ms
43,640 KB
testcase_08 AC 503 ms
43,896 KB
testcase_09 AC 505 ms
43,508 KB
testcase_10 AC 508 ms
43,884 KB
testcase_11 AC 514 ms
43,768 KB
testcase_12 AC 505 ms
43,628 KB
testcase_13 AC 494 ms
43,756 KB
testcase_14 AC 611 ms
47,620 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:
    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