結果

問題 No.472 平均順位
ユーザー 👑 rin204rin204
提出日時 2022-07-08 09:47:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 995 ms / 2,000 ms
コード長 419 bytes
コンパイル時間 949 ms
コンパイル使用メモリ 86,848 KB
実行使用メモリ 78,352 KB
最終ジャッジ日時 2023-08-27 02:34:08
合計ジャッジ時間 7,446 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,252 KB
testcase_01 AC 73 ms
71,272 KB
testcase_02 AC 73 ms
71,400 KB
testcase_03 AC 74 ms
71,352 KB
testcase_04 AC 87 ms
75,776 KB
testcase_05 AC 72 ms
71,348 KB
testcase_06 AC 82 ms
75,992 KB
testcase_07 AC 102 ms
76,200 KB
testcase_08 AC 126 ms
78,352 KB
testcase_09 AC 156 ms
77,928 KB
testcase_10 AC 141 ms
78,332 KB
testcase_11 AC 209 ms
77,908 KB
testcase_12 AC 187 ms
77,888 KB
testcase_13 AC 361 ms
78,028 KB
testcase_14 AC 900 ms
78,124 KB
testcase_15 AC 394 ms
77,928 KB
testcase_16 AC 995 ms
77,836 KB
testcase_17 AC 857 ms
78,060 KB
testcase_18 AC 174 ms
77,904 KB
testcase_19 AC 235 ms
77,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, p = map(int, input().split())
dp = [1 << 30] * (p + 1)
dp[0] = 0
for _ in range(n):
    a, b, c = map(int, input().split())
    for i in range(p, -1, -1):
        mi = dp[i] + a
        if i >= 1:
            mi = min(mi, dp[i - 1] + b)
            if i >= 2:
                mi = min(mi, dp[i - 2] + c)
                if i >= 3:
                    mi = min(mi, dp[i - 3] + 1)
        dp[i] = mi

print(dp[-1] / n)
0