結果

問題 No.951 【本日限定】1枚頼むともう1枚無料!
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2022-04-04 12:49:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 608 ms / 2,000 ms
コード長 542 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 78,460 KB
最終ジャッジ日時 2023-08-16 14:19:53
合計ジャッジ時間 15,742 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,424 KB
testcase_01 AC 67 ms
71,380 KB
testcase_02 AC 80 ms
75,852 KB
testcase_03 AC 71 ms
75,448 KB
testcase_04 AC 72 ms
71,364 KB
testcase_05 AC 72 ms
71,596 KB
testcase_06 AC 79 ms
75,760 KB
testcase_07 AC 70 ms
71,452 KB
testcase_08 AC 77 ms
75,800 KB
testcase_09 AC 104 ms
76,548 KB
testcase_10 AC 94 ms
75,972 KB
testcase_11 AC 96 ms
76,396 KB
testcase_12 AC 183 ms
77,448 KB
testcase_13 AC 414 ms
78,196 KB
testcase_14 AC 140 ms
76,680 KB
testcase_15 AC 137 ms
77,416 KB
testcase_16 AC 156 ms
78,128 KB
testcase_17 AC 172 ms
78,312 KB
testcase_18 AC 73 ms
71,216 KB
testcase_19 AC 70 ms
71,436 KB
testcase_20 AC 72 ms
71,280 KB
testcase_21 AC 96 ms
75,872 KB
testcase_22 AC 95 ms
75,828 KB
testcase_23 AC 93 ms
76,064 KB
testcase_24 AC 448 ms
78,404 KB
testcase_25 AC 491 ms
78,196 KB
testcase_26 AC 483 ms
78,400 KB
testcase_27 AC 468 ms
78,092 KB
testcase_28 AC 321 ms
78,268 KB
testcase_29 AC 317 ms
78,272 KB
testcase_30 AC 72 ms
71,424 KB
testcase_31 AC 70 ms
71,448 KB
testcase_32 AC 93 ms
75,656 KB
testcase_33 AC 94 ms
76,144 KB
testcase_34 AC 97 ms
75,964 KB
testcase_35 AC 405 ms
78,332 KB
testcase_36 AC 480 ms
78,308 KB
testcase_37 AC 421 ms
78,264 KB
testcase_38 AC 507 ms
78,272 KB
testcase_39 AC 608 ms
78,204 KB
testcase_40 AC 475 ms
78,116 KB
testcase_41 AC 410 ms
78,248 KB
testcase_42 AC 539 ms
78,460 KB
testcase_43 AC 470 ms
78,428 KB
testcase_44 AC 534 ms
78,424 KB
testcase_45 AC 408 ms
78,408 KB
testcase_46 AC 322 ms
78,192 KB
testcase_47 AC 326 ms
78,384 KB
testcase_48 AC 320 ms
78,320 KB
testcase_49 AC 316 ms
78,324 KB
testcase_50 AC 305 ms
78,228 KB
testcase_51 AC 319 ms
78,208 KB
testcase_52 AC 261 ms
78,308 KB
testcase_53 AC 284 ms
78,064 KB
testcase_54 AC 188 ms
78,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main1(n,k,pd):
    pd.sort(key=lambda x:x[0],reverse=True)
    dp0=[-1]*(k+1)
    dp1=[-1]*(k+1)
    dp0[0]=0
    for p,d in pd:
        for i in range(k,-1,-1):
            if dp1[i]>=0:
                dp0[i]=max(dp0[i],dp1[i]+d)   # チケット使う
            if i-p>=0 and dp0[i-p]>=0:
                dp1[i]=max(dp1[i],dp0[i-p]+d) # 買う
    return max(max(dp0),max(dp1))
if __name__=='__main__':
    n,k=map(int,input().split())
    pd=[list(map(int,input().split())) for _ in range(n)]
    ret1=main1(n,k,pd)
    print(ret1)
0