結果

問題 No.2701 A cans -> B cans
ユーザー hirayuu_ychirayuu_yc
提出日時 2024-02-29 16:44:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 667 ms / 1,000 ms
コード長 614 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 77,348 KB
最終ジャッジ日時 2024-02-29 18:15:59
合計ジャッジ時間 23,155 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,460 KB
testcase_01 AC 34 ms
53,460 KB
testcase_02 AC 34 ms
53,460 KB
testcase_03 AC 54 ms
66,528 KB
testcase_04 AC 55 ms
66,528 KB
testcase_05 AC 55 ms
66,528 KB
testcase_06 AC 59 ms
66,528 KB
testcase_07 AC 55 ms
66,528 KB
testcase_08 AC 55 ms
66,528 KB
testcase_09 AC 55 ms
66,528 KB
testcase_10 AC 56 ms
66,528 KB
testcase_11 AC 55 ms
66,528 KB
testcase_12 AC 55 ms
66,528 KB
testcase_13 AC 55 ms
66,528 KB
testcase_14 AC 55 ms
66,528 KB
testcase_15 AC 55 ms
66,528 KB
testcase_16 AC 55 ms
66,528 KB
testcase_17 AC 55 ms
66,528 KB
testcase_18 AC 56 ms
66,528 KB
testcase_19 AC 56 ms
66,528 KB
testcase_20 AC 57 ms
66,528 KB
testcase_21 AC 56 ms
66,528 KB
testcase_22 AC 57 ms
66,528 KB
testcase_23 AC 288 ms
77,152 KB
testcase_24 AC 290 ms
77,152 KB
testcase_25 AC 302 ms
77,164 KB
testcase_26 AC 369 ms
77,192 KB
testcase_27 AC 342 ms
77,208 KB
testcase_28 AC 379 ms
77,328 KB
testcase_29 AC 352 ms
77,208 KB
testcase_30 AC 489 ms
77,216 KB
testcase_31 AC 456 ms
77,216 KB
testcase_32 AC 352 ms
77,336 KB
testcase_33 AC 367 ms
77,316 KB
testcase_34 AC 352 ms
77,328 KB
testcase_35 AC 351 ms
77,200 KB
testcase_36 AC 483 ms
77,220 KB
testcase_37 AC 347 ms
77,200 KB
testcase_38 AC 348 ms
77,216 KB
testcase_39 AC 358 ms
77,348 KB
testcase_40 AC 452 ms
77,196 KB
testcase_41 AC 363 ms
77,328 KB
testcase_42 AC 363 ms
77,328 KB
testcase_43 AC 359 ms
77,336 KB
testcase_44 AC 360 ms
77,208 KB
testcase_45 AC 481 ms
77,328 KB
testcase_46 AC 480 ms
77,216 KB
testcase_47 AC 493 ms
77,328 KB
testcase_48 AC 341 ms
77,216 KB
testcase_49 AC 478 ms
77,328 KB
testcase_50 AC 352 ms
77,208 KB
testcase_51 AC 357 ms
77,328 KB
testcase_52 AC 375 ms
77,208 KB
testcase_53 AC 373 ms
77,344 KB
testcase_54 AC 336 ms
77,216 KB
testcase_55 AC 334 ms
77,216 KB
testcase_56 AC 62 ms
70,692 KB
testcase_57 AC 67 ms
73,272 KB
testcase_58 AC 66 ms
73,284 KB
testcase_59 AC 63 ms
70,692 KB
testcase_60 AC 59 ms
68,600 KB
testcase_61 AC 67 ms
73,264 KB
testcase_62 AC 78 ms
76,236 KB
testcase_63 AC 61 ms
70,704 KB
testcase_64 AC 65 ms
71,192 KB
testcase_65 AC 65 ms
71,176 KB
testcase_66 AC 660 ms
77,216 KB
testcase_67 AC 440 ms
77,216 KB
testcase_68 AC 439 ms
77,208 KB
testcase_69 AC 629 ms
77,208 KB
testcase_70 AC 657 ms
77,212 KB
testcase_71 AC 625 ms
77,220 KB
testcase_72 AC 626 ms
77,212 KB
testcase_73 AC 437 ms
77,208 KB
testcase_74 AC 667 ms
77,212 KB
testcase_75 AC 436 ms
77,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#sys.setrecursionlimit((1<<19)-1)
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')
input=sys.stdin.buffer.readline
inf=(1<<61)-1

N,M=map(int,input().split())
can=[tuple(map(int,input().split())) for i in range(N)]
dp=[-inf]*(M+1)
dp[0]=0
for a,b,c in can:
    ndp=[-inf]*(M+1)
    for i in range(M+1):
        if i+a>M:
            break
        ndp[i+a]=dp[i]+b*c
    for i in range(M+1):
        if i+a-b>M:
            break
        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])
ans=0
for i in range(M):
	ans=max(ans,dp[i+1])
	print(ans)
0