結果

問題 No.951 【本日限定】1枚頼むともう1枚無料!
ユーザー brthyyjpbrthyyjp
提出日時 2021-04-21 14:57:20
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 857 bytes
コンパイル時間 364 ms
コンパイル使用メモリ 86,780 KB
実行使用メモリ 216,364 KB
最終ジャッジ日時 2023-09-17 09:31:29
合計ジャッジ時間 13,132 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
75,388 KB
testcase_01 AC 77 ms
75,764 KB
testcase_02 AC 88 ms
76,068 KB
testcase_03 AC 80 ms
75,876 KB
testcase_04 AC 78 ms
75,976 KB
testcase_05 AC 73 ms
71,040 KB
testcase_06 AC 90 ms
76,136 KB
testcase_07 AC 80 ms
75,796 KB
testcase_08 AC 89 ms
76,112 KB
testcase_09 AC 186 ms
79,248 KB
testcase_10 AC 146 ms
78,192 KB
testcase_11 AC 145 ms
77,820 KB
testcase_12 AC 830 ms
106,808 KB
testcase_13 TLE -
testcase_14 AC 527 ms
94,908 KB
testcase_15 AC 436 ms
91,676 KB
testcase_16 AC 590 ms
91,776 KB
testcase_17 AC 707 ms
87,416 KB
testcase_18 AC 72 ms
70,948 KB
testcase_19 AC 73 ms
70,956 KB
testcase_20 AC 73 ms
71,164 KB
testcase_21 AC 150 ms
78,940 KB
testcase_22 AC 125 ms
77,592 KB
testcase_23 AC 136 ms
78,072 KB
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import io, os
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

n, k = map(int, input().split())
PD = []
for i in range(n):
    p, d = map(int, input().split())
    PD.append((p,d))

PD.sort(key=lambda x: -x[0])
INF = 10**18
dp = [[-INF]*2 for i in range(k+1)]
dp[0][0] = 0
for p, d in PD:
    nx = [[-INF]*2 for i in range(k+1)]
    for i in range(k+1):
        for j in range(2):
            nx[i][j] = max(nx[i][j], dp[i][j])
    for i in range(k+1):
        for j in range(2):
            if dp[i][j] == -INF:
                continue
            if j == 0:
                if i+p <= k:
                    nx[i+p][1] = max(nx[i+p][1], dp[i][j]+d)
            else:
                nx[i][0] = max(nx[i][0], dp[i][j]+d)
    dp = nx

ans = -INF
for i in range(k+1):
    for j in range(2):
        ans = max(ans, dp[i][j])
print(ans)
0