結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
86,572 KB
testcase_01 AC 104 ms
79,572 KB
testcase_02 AC 104 ms
79,560 KB
testcase_03 AC 102 ms
79,564 KB
testcase_04 AC 132 ms
80,868 KB
testcase_05 AC 105 ms
79,568 KB
testcase_06 AC 118 ms
80,196 KB
testcase_07 AC 154 ms
81,464 KB
testcase_08 AC 192 ms
84,976 KB
testcase_09 AC 324 ms
112,372 KB
testcase_10 AC 269 ms
95,484 KB
testcase_11 AC 629 ms
178,992 KB
testcase_12 AC 495 ms
135,384 KB
testcase_13 MLE -
testcase_14 MLE -
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