結果

問題 No.951 【本日限定】1枚頼むともう1枚無料!
ユーザー AEnAEn
提出日時 2023-05-26 00:26:46
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 649 bytes
コンパイル時間 300 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 87,384 KB
最終ジャッジ日時 2023-08-26 01:05:37
合計ジャッジ時間 58,053 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,320 KB
testcase_01 AC 78 ms
76,172 KB
testcase_02 AC 97 ms
76,420 KB
testcase_03 AC 81 ms
76,440 KB
testcase_04 AC 78 ms
76,312 KB
testcase_05 AC 73 ms
71,508 KB
testcase_06 AC 93 ms
76,472 KB
testcase_07 AC 77 ms
76,200 KB
testcase_08 AC 91 ms
76,432 KB
testcase_09 AC 169 ms
78,360 KB
testcase_10 AC 142 ms
77,704 KB
testcase_11 AC 143 ms
77,840 KB
testcase_12 AC 565 ms
80,852 KB
testcase_13 AC 1,627 ms
83,484 KB
testcase_14 AC 393 ms
79,932 KB
testcase_15 AC 317 ms
79,440 KB
testcase_16 AC 412 ms
79,692 KB
testcase_17 AC 473 ms
79,780 KB
testcase_18 AC 74 ms
71,520 KB
testcase_19 AC 75 ms
71,268 KB
testcase_20 AC 75 ms
71,276 KB
testcase_21 AC 151 ms
78,196 KB
testcase_22 AC 139 ms
77,480 KB
testcase_23 AC 145 ms
78,224 KB
testcase_24 TLE -
testcase_25 TLE -
testcase_26 AC 1,976 ms
86,448 KB
testcase_27 TLE -
testcase_28 AC 1,629 ms
85,968 KB
testcase_29 AC 1,549 ms
86,228 KB
testcase_30 AC 73 ms
71,492 KB
testcase_31 AC 73 ms
71,272 KB
testcase_32 AC 134 ms
77,648 KB
testcase_33 AC 153 ms
78,284 KB
testcase_34 AC 164 ms
78,832 KB
testcase_35 TLE -
testcase_36 TLE -
testcase_37 TLE -
testcase_38 AC 1,999 ms
87,264 KB
testcase_39 TLE -
testcase_40 TLE -
testcase_41 TLE -
testcase_42 AC 1,920 ms
86,628 KB
testcase_43 AC 1,827 ms
85,956 KB
testcase_44 TLE -
testcase_45 AC 1,899 ms
86,476 KB
testcase_46 AC 1,519 ms
85,888 KB
testcase_47 AC 1,513 ms
86,812 KB
testcase_48 AC 1,565 ms
85,844 KB
testcase_49 AC 1,505 ms
86,936 KB
testcase_50 AC 1,579 ms
87,384 KB
testcase_51 AC 1,541 ms
86,796 KB
testcase_52 AC 1,330 ms
82,628 KB
testcase_53 AC 1,557 ms
85,848 KB
testcase_54 AC 1,064 ms
86,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

piza.sort(key = lambda x:(-x[0]))
dp = [[-float('inf')]*(K+1) for _ in range(2)]
dp[1][0] = 0
for i in range(N):
    P,D = piza[i]
    ndp = [[-float('inf')]*(K+1) for _ in range(2)]
    for j in range(2):
        for k in range(K+1):
            ndp[j][k] = max(ndp[j][k],dp[j][k])
            if j:
                ndp[j][k] = max(ndp[j][k],dp[j-1][k]+D)
            if j==0 and k+P<=K:
                ndp[j][k+P] = max(ndp[j][k+P],dp[j+1][k]+D)
    dp = ndp
res = 0
for i in range(2):
    for j in range(K+1):
        res = max(res,dp[i][j])
print(res)
0