結果

問題 No.1947 質より種類数
ユーザー 👑 H20H20
提出日時 2022-04-10 18:38:55
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 555 bytes
コンパイル時間 823 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 78,324 KB
最終ジャッジ日時 2023-08-23 06:29:56
合計ジャッジ時間 6,480 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,260 KB
testcase_01 AC 69 ms
71,408 KB
testcase_02 AC 67 ms
71,492 KB
testcase_03 AC 68 ms
71,408 KB
testcase_04 AC 87 ms
76,304 KB
testcase_05 AC 85 ms
76,168 KB
testcase_06 AC 83 ms
76,236 KB
testcase_07 AC 84 ms
76,092 KB
testcase_08 AC 87 ms
76,348 KB
testcase_09 AC 102 ms
76,896 KB
testcase_10 AC 93 ms
76,208 KB
testcase_11 AC 119 ms
77,508 KB
testcase_12 AC 108 ms
76,616 KB
testcase_13 AC 94 ms
76,196 KB
testcase_14 WA -
testcase_15 AC 172 ms
77,504 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 112 ms
77,392 KB
testcase_23 WA -
testcase_24 AC 87 ms
76,356 KB
testcase_25 AC 85 ms
76,304 KB
testcase_26 AC 80 ms
76,208 KB
testcase_27 AC 82 ms
76,168 KB
testcase_28 AC 88 ms
76,216 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 73 ms
71,560 KB
testcase_32 AC 72 ms
71,564 KB
testcase_33 AC 80 ms
76,132 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

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