結果

問題 No.2701 A cans -> B cans
ユーザー sotanishy
提出日時 2024-03-29 22:13:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 650 ms / 1,000 ms
コード長 434 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 82,380 KB
実行使用メモリ 77,440 KB
最終ジャッジ日時 2024-10-09 17:39:28
合計ジャッジ時間 22,341 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 73
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.readline

N, M = map(int, input().split())
dp = [0] * (M + 1)
for _ in range(N):
    a, b, c = map(int, input().split())
    ndp = [-(10**18)] * (M + 1)
    for i in range(M - a + 1):
        ndp[i + a] = dp[i] + b * c
    for i in range(M - (a - b) + 1):
        ndp[i + a - b] = max(ndp[i + a - b], ndp[i] + b * c)
    for i in range(M + 1):
        dp[i] = max(dp[i], ndp[i])
print(*dp[1:], sep="\n")
0