結果

問題 No.472 平均順位
ユーザー terrafarmterrafarm
提出日時 2020-12-14 06:55:28
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,196 bytes
コンパイル時間 401 ms
コンパイル使用メモリ 81,740 KB
実行使用メモリ 391,560 KB
最終ジャッジ日時 2023-10-20 04:44:09
合計ジャッジ時間 9,483 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 AC 100 ms
79,616 KB
testcase_02 AC 101 ms
79,632 KB
testcase_03 AC 100 ms
79,608 KB
testcase_04 AC 140 ms
81,140 KB
testcase_05 AC 102 ms
79,628 KB
testcase_06 AC 118 ms
80,256 KB
testcase_07 AC 161 ms
81,824 KB
testcase_08 AC 251 ms
88,316 KB
testcase_09 AC 531 ms
113,808 KB
testcase_10 AC 458 ms
101,868 KB
testcase_11 AC 1,152 ms
183,040 KB
testcase_12 AC 931 ms
153,132 KB
testcase_13 MLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import logging
import sys
from inspect import currentframe

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

logging.basicConfig(level=logging.DEBUG)


def dbg(*args):
    id2names = {id(v): k for k, v in currentframe().f_back.f_locals.items()}
    logging.debug(
        ", ".join(id2names.get(id(arg), "???") + " = " + repr(arg) for arg in args)
    )


def main():

    INF = float("inf")
    n, p = map(int, input().split())
    a = [0] * n
    b = [0] * n
    c = [0] * n
    for i in range(n):
        a[i], b[i], c[i] = map(int, input().split())
    dp = [[INF] * (p + 1) for _ in range(n + 1)]
    dp[0][0] = 0
    for i in range(n):
        for j in range(p + 1):
            if j <= p:
                dp[i + 1][j] = min(dp[i][j] + a[i], dp[i + 1][j])
            if j + 1 <= p:
                dp[i + 1][j + 1] = min(dp[i][j] + b[i], dp[i + 1][j + 1])
            if j + 2 <= p:
                dp[i + 1][j + 2] = min(dp[i][j] + c[i], dp[i + 1][j + 2])
            if j + 3 <= p:
                dp[i + 1][j + 3] = min(dp[i][j] + 1, dp[i + 1][j + 3])
    for i in range(n + 1):
        dbg(dp[i])
    ans = dp[n][p] / n
    print(ans)


if __name__ == "__main__":
    main()
0