結果

問題 No.951 【本日限定】1枚頼むともう1枚無料!
ユーザー ttrttr
提出日時 2020-01-30 21:08:49
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 663 bytes
コンパイル時間 950 ms
コンパイル使用メモリ 86,912 KB
実行使用メモリ 470,504 KB
最終ジャッジ日時 2023-10-14 08:47:21
合計ジャッジ時間 47,016 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,240 KB
testcase_01 AC 73 ms
71,504 KB
testcase_02 AC 90 ms
76,044 KB
testcase_03 AC 80 ms
75,868 KB
testcase_04 AC 75 ms
71,272 KB
testcase_05 AC 74 ms
71,212 KB
testcase_06 AC 90 ms
76,216 KB
testcase_07 AC 74 ms
71,004 KB
testcase_08 AC 85 ms
75,948 KB
testcase_09 AC 135 ms
86,300 KB
testcase_10 AC 122 ms
81,800 KB
testcase_11 AC 119 ms
82,356 KB
testcase_12 AC 448 ms
150,544 KB
testcase_13 AC 1,370 ms
351,848 KB
testcase_14 AC 281 ms
111,440 KB
testcase_15 AC 279 ms
125,436 KB
testcase_16 AC 319 ms
148,852 KB
testcase_17 AC 362 ms
167,404 KB
testcase_18 AC 72 ms
71,344 KB
testcase_19 AC 75 ms
71,172 KB
testcase_20 AC 74 ms
71,380 KB
testcase_21 AC 115 ms
81,344 KB
testcase_22 AC 102 ms
76,568 KB
testcase_23 AC 107 ms
76,672 KB
testcase_24 AC 1,764 ms
470,324 KB
testcase_25 AC 1,884 ms
470,088 KB
testcase_26 AC 1,531 ms
470,204 KB
testcase_27 AC 1,565 ms
470,020 KB
testcase_28 AC 1,142 ms
470,036 KB
testcase_29 AC 1,154 ms
469,888 KB
testcase_30 AC 73 ms
71,044 KB
testcase_31 AC 73 ms
71,220 KB
testcase_32 AC 102 ms
76,564 KB
testcase_33 AC 107 ms
76,800 KB
testcase_34 AC 124 ms
84,676 KB
testcase_35 AC 1,956 ms
470,180 KB
testcase_36 AC 1,935 ms
470,400 KB
testcase_37 AC 1,996 ms
470,504 KB
testcase_38 AC 1,995 ms
470,296 KB
testcase_39 TLE -
testcase_40 AC 1,636 ms
470,100 KB
testcase_41 AC 1,613 ms
470,024 KB
testcase_42 AC 1,594 ms
470,168 KB
testcase_43 AC 1,613 ms
470,340 KB
testcase_44 AC 1,579 ms
470,228 KB
testcase_45 AC 1,586 ms
470,248 KB
testcase_46 AC 1,176 ms
470,112 KB
testcase_47 AC 1,161 ms
469,884 KB
testcase_48 AC 1,142 ms
469,852 KB
testcase_49 AC 1,136 ms
469,948 KB
testcase_50 AC 1,136 ms
469,832 KB
testcase_51 AC 1,133 ms
470,144 KB
testcase_52 AC 1,320 ms
393,536 KB
testcase_53 AC 1,561 ms
470,124 KB
testcase_54 AC 856 ms
470,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int, input().split())
L = [[int(l) for l in input().split()] for _ in range(N)]

L.sort(reverse=True)
dp0 = [[0]*(K+1) for _ in range(N+1)]
dp1 = [[0]*(K+1) for _ in range(N+1)]
for i in range(N):
    for j in range(K+1):
        if j < L[i][0] and dp1[i][j] > 0:
            dp0[i+1][j] = max(dp0[i][j], dp1[i][j]+L[i][1])
        elif j < L[i][0]:
            dp0[i+1][j] = dp0[i][j]
        else:
            if dp1[i][j] > 0:
                dp0[i+1][j] = max(dp0[i][j], dp1[i][j]+L[i][1])
            else:
                dp0[i+1][j] = dp0[i][j]
            dp1[i+1][j] = max(dp1[i][j], dp0[i][j-L[i][0]]+L[i][1])

print(max(dp0[N][K], dp1[N][K]))
0