結果

問題 No.472 平均順位
ユーザー terrafarmterrafarm
提出日時 2020-12-14 06:52:39
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,196 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 81,904 KB
実行使用メモリ 316,432 KB
最終ジャッジ日時 2023-10-20 04:43:35
合計ジャッジ時間 8,996 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
79,784 KB
testcase_01 AC 95 ms
79,756 KB
testcase_02 AC 95 ms
79,756 KB
testcase_03 AC 96 ms
79,756 KB
testcase_04 AC 131 ms
81,180 KB
testcase_05 AC 97 ms
79,760 KB
testcase_06 AC 109 ms
80,280 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 438 ms
101,968 KB
testcase_11 WA -
testcase_12 WA -
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 <= n:
                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