結果

問題 No.951 【本日限定】1枚頼むともう1枚無料!
ユーザー 👑 rin204rin204
提出日時 2022-02-12 23:06:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 645 ms / 2,000 ms
コード長 412 bytes
コンパイル時間 546 ms
コンパイル使用メモリ 87,144 KB
実行使用メモリ 79,352 KB
最終ジャッジ日時 2023-09-11 11:47:29
合計ジャッジ時間 22,118 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,252 KB
testcase_01 AC 76 ms
71,368 KB
testcase_02 AC 85 ms
75,956 KB
testcase_03 AC 81 ms
76,072 KB
testcase_04 AC 77 ms
71,380 KB
testcase_05 AC 76 ms
71,376 KB
testcase_06 AC 83 ms
76,020 KB
testcase_07 AC 77 ms
71,476 KB
testcase_08 AC 82 ms
75,796 KB
testcase_09 AC 127 ms
77,372 KB
testcase_10 AC 107 ms
76,976 KB
testcase_11 AC 105 ms
76,328 KB
testcase_12 AC 214 ms
78,492 KB
testcase_13 AC 488 ms
78,828 KB
testcase_14 AC 168 ms
78,156 KB
testcase_15 AC 162 ms
77,992 KB
testcase_16 AC 198 ms
78,272 KB
testcase_17 AC 219 ms
78,856 KB
testcase_18 AC 75 ms
71,644 KB
testcase_19 AC 77 ms
71,620 KB
testcase_20 AC 78 ms
71,352 KB
testcase_21 AC 103 ms
76,440 KB
testcase_22 AC 99 ms
76,500 KB
testcase_23 AC 101 ms
76,640 KB
testcase_24 AC 582 ms
78,972 KB
testcase_25 AC 642 ms
78,916 KB
testcase_26 AC 633 ms
79,032 KB
testcase_27 AC 626 ms
78,928 KB
testcase_28 AC 507 ms
78,844 KB
testcase_29 AC 507 ms
78,892 KB
testcase_30 AC 77 ms
71,256 KB
testcase_31 AC 76 ms
71,256 KB
testcase_32 AC 102 ms
77,112 KB
testcase_33 AC 103 ms
77,048 KB
testcase_34 AC 113 ms
77,332 KB
testcase_35 AC 595 ms
79,352 KB
testcase_36 AC 594 ms
79,052 KB
testcase_37 AC 640 ms
79,096 KB
testcase_38 AC 636 ms
79,096 KB
testcase_39 AC 629 ms
79,020 KB
testcase_40 AC 619 ms
78,944 KB
testcase_41 AC 645 ms
78,828 KB
testcase_42 AC 627 ms
79,076 KB
testcase_43 AC 641 ms
78,876 KB
testcase_44 AC 623 ms
78,752 KB
testcase_45 AC 623 ms
78,956 KB
testcase_46 AC 531 ms
78,712 KB
testcase_47 AC 587 ms
79,160 KB
testcase_48 AC 581 ms
78,936 KB
testcase_49 AC 576 ms
78,944 KB
testcase_50 AC 502 ms
78,688 KB
testcase_51 AC 506 ms
78,904 KB
testcase_52 AC 409 ms
78,300 KB
testcase_53 AC 478 ms
78,420 KB
testcase_54 AC 392 ms
78,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
pd = [list(map(int, input().split())) for _ in range(n)]
pd.sort()
dp = [[0] * 2 for _ in range(k + 1)]
for p, d in pd:
    for j in range(k, p - 1, -1):
        dp[j][0] = max(dp[j][0], dp[j][1] + d)
        dp[j][1] = max(dp[j][1], dp[j - p][0] + d)
    for j in range(p - 1, -1, -1):
        dp[j][0] = max(dp[j][0], dp[j][1] + d)

ans = max(v for _, v in dp)
print(ans)
    
0