結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 524 ms
43,996 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

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]
        print(p)
    p /= N
    expected += p
    add(dp, x)

print(expected)
0