結果

問題 No.951 【本日限定】1枚頼むともう1枚無料!
ユーザー titia
提出日時 2020-01-04 20:26:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 484 ms / 2,000 ms
コード長 375 bytes
コンパイル時間 654 ms
コンパイル使用メモリ 81,596 KB
実行使用メモリ 77,416 KB
最終ジャッジ日時 2024-11-22 21:29:11
合計ジャッジ時間 13,137 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 52
権限があれば一括ダウンロードができます

ソースコード

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