結果

問題 No.951 【本日限定】1枚頼むともう1枚無料!
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2022-04-04 12:47:01
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 548 bytes
コンパイル時間 824 ms
コンパイル使用メモリ 87,128 KB
実行使用メモリ 78,404 KB
最終ジャッジ日時 2023-08-16 14:17:30
合計ジャッジ時間 16,595 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 71 ms
71,180 KB
testcase_02 AC 82 ms
75,740 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 71 ms
71,088 KB
testcase_06 AC 80 ms
75,780 KB
testcase_07 AC 71 ms
71,276 KB
testcase_08 AC 79 ms
75,612 KB
testcase_09 AC 102 ms
76,288 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 187 ms
77,532 KB
testcase_13 AC 428 ms
78,136 KB
testcase_14 AC 142 ms
76,776 KB
testcase_15 WA -
testcase_16 AC 153 ms
78,128 KB
testcase_17 AC 171 ms
78,368 KB
testcase_18 AC 73 ms
71,300 KB
testcase_19 AC 72 ms
71,420 KB
testcase_20 AC 72 ms
71,424 KB
testcase_21 AC 97 ms
75,704 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 445 ms
78,316 KB
testcase_25 AC 491 ms
78,252 KB
testcase_26 AC 483 ms
78,220 KB
testcase_27 AC 480 ms
78,148 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 71 ms
71,196 KB
testcase_31 AC 72 ms
71,204 KB
testcase_32 AC 92 ms
76,108 KB
testcase_33 AC 94 ms
75,748 KB
testcase_34 AC 96 ms
75,700 KB
testcase_35 AC 396 ms
78,124 KB
testcase_36 AC 480 ms
78,244 KB
testcase_37 AC 426 ms
78,328 KB
testcase_38 AC 514 ms
78,256 KB
testcase_39 AC 602 ms
78,344 KB
testcase_40 AC 471 ms
78,220 KB
testcase_41 AC 411 ms
78,332 KB
testcase_42 AC 546 ms
78,344 KB
testcase_43 AC 480 ms
78,404 KB
testcase_44 AC 537 ms
78,360 KB
testcase_45 AC 407 ms
78,368 KB
testcase_46 AC 322 ms
78,036 KB
testcase_47 AC 312 ms
78,292 KB
testcase_48 AC 312 ms
78,256 KB
testcase_49 AC 310 ms
78,188 KB
testcase_50 AC 307 ms
78,136 KB
testcase_51 WA -
testcase_52 AC 262 ms
78,192 KB
testcase_53 AC 282 ms
78,188 KB
testcase_54 AC 192 ms
78,168 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,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)
    exit()
0