結果

問題 No.951 【本日限定】1枚頼むともう1枚無料!
ユーザー titiatitia
提出日時 2020-01-04 20:26:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 519 ms / 2,000 ms
コード長 375 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 87,224 KB
実行使用メモリ 78,776 KB
最終ジャッジ日時 2023-08-14 20:44:53
合計ジャッジ時間 15,247 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,016 KB
testcase_01 AC 71 ms
71,340 KB
testcase_02 AC 82 ms
75,624 KB
testcase_03 AC 77 ms
75,724 KB
testcase_04 AC 72 ms
71,024 KB
testcase_05 AC 70 ms
71,088 KB
testcase_06 AC 80 ms
75,660 KB
testcase_07 AC 71 ms
71,100 KB
testcase_08 AC 77 ms
75,728 KB
testcase_09 AC 104 ms
76,368 KB
testcase_10 AC 96 ms
76,120 KB
testcase_11 AC 97 ms
76,424 KB
testcase_12 AC 170 ms
77,748 KB
testcase_13 AC 358 ms
78,024 KB
testcase_14 AC 135 ms
77,312 KB
testcase_15 AC 129 ms
76,744 KB
testcase_16 AC 152 ms
77,588 KB
testcase_17 AC 163 ms
77,996 KB
testcase_18 AC 71 ms
71,132 KB
testcase_19 AC 72 ms
70,984 KB
testcase_20 AC 72 ms
71,192 KB
testcase_21 AC 93 ms
76,044 KB
testcase_22 AC 92 ms
75,924 KB
testcase_23 AC 91 ms
75,944 KB
testcase_24 AC 372 ms
78,776 KB
testcase_25 AC 380 ms
77,948 KB
testcase_26 AC 398 ms
78,016 KB
testcase_27 AC 407 ms
78,128 KB
testcase_28 AC 310 ms
78,004 KB
testcase_29 AC 310 ms
78,028 KB
testcase_30 AC 71 ms
71,132 KB
testcase_31 AC 72 ms
71,112 KB
testcase_32 AC 90 ms
75,780 KB
testcase_33 AC 95 ms
75,960 KB
testcase_34 AC 95 ms
76,092 KB
testcase_35 AC 519 ms
78,192 KB
testcase_36 AC 419 ms
78,768 KB
testcase_37 AC 417 ms
77,876 KB
testcase_38 AC 427 ms
78,256 KB
testcase_39 AC 405 ms
77,984 KB
testcase_40 AC 414 ms
77,940 KB
testcase_41 AC 431 ms
77,964 KB
testcase_42 AC 412 ms
78,488 KB
testcase_43 AC 424 ms
78,000 KB
testcase_44 AC 423 ms
78,112 KB
testcase_45 AC 408 ms
78,736 KB
testcase_46 AC 313 ms
77,880 KB
testcase_47 AC 308 ms
78,040 KB
testcase_48 AC 310 ms
78,284 KB
testcase_49 AC 304 ms
77,904 KB
testcase_50 AC 307 ms
78,156 KB
testcase_51 AC 303 ms
77,896 KB
testcase_52 AC 337 ms
77,924 KB
testcase_53 AC 355 ms
77,884 KB
testcase_54 AC 197 ms
77,820 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,input().split())
P=[tuple(map(int,input().split())) for i in range(N)]

P.sort(reverse=True)

BUY=[0]*(K+1)
SERVICE=[0]*(K+1)

for p,d in P:
    for i in range(K,-1,-1):
        if BUY[i]!=0:
            SERVICE[i]=max(SERVICE[i],BUY[i]+d)
        if i>=p:
            BUY[i]=max(BUY[i],SERVICE[i-p]+d)

    #print(BUY,SERVICE)

print(max(max(BUY),max(SERVICE)))
0