結果

問題 No.1947 質より種類数
ユーザー H20
提出日時 2022-04-10 18:38:55
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 555 bytes
コンパイル時間 402 ms
コンパイル使用メモリ 81,652 KB
実行使用メモリ 76,172 KB
最終ジャッジ日時 2024-12-21 06:51:15
合計ジャッジ時間 4,041 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

N,V,C = map(int, input().split())
VW = [list(map(int, input().split())) for _ in range(N)]
if not (1<=N<=1000 and 1<=V<=5000 and 1<=C<=5000):
    exit()
for v,w in VW:
    if 1<=v<=5000 and 1<=w<=5000:
        continue
    exit()

DP = [0]*(V+1)
for v,w in VW:
    w+=C
    for i in reversed(range(V)):
        if DP[i]>0 and i+v<=V and DP[i+v]<DP[i]+w:
            DP[i+v]=DP[i]+w
    if v<=V and DP[v]<w:
        DP[v]=w
for v,w in VW:
    for i in range(V):
        if DP[i]>0 and i+v<=V and DP[i+v]<DP[i]+w:
            DP[i+v]=DP[i]+w
print(max(DP))
0