結果

問題 No.1947 質より種類数
ユーザー 👑 H20H20
提出日時 2022-04-10 18:44:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 628 ms / 2,000 ms
コード長 555 bytes
コンパイル時間 328 ms
コンパイル使用メモリ 87,036 KB
実行使用メモリ 78,620 KB
最終ジャッジ日時 2023-08-23 06:29:39
合計ジャッジ時間 10,675 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,624 KB
testcase_01 AC 73 ms
71,196 KB
testcase_02 AC 71 ms
71,488 KB
testcase_03 AC 77 ms
71,344 KB
testcase_04 AC 89 ms
76,204 KB
testcase_05 AC 90 ms
76,300 KB
testcase_06 AC 85 ms
76,408 KB
testcase_07 AC 87 ms
76,412 KB
testcase_08 AC 89 ms
76,568 KB
testcase_09 AC 102 ms
77,124 KB
testcase_10 AC 97 ms
76,264 KB
testcase_11 AC 121 ms
77,604 KB
testcase_12 AC 110 ms
76,612 KB
testcase_13 AC 96 ms
76,440 KB
testcase_14 AC 264 ms
78,492 KB
testcase_15 AC 174 ms
77,644 KB
testcase_16 AC 337 ms
78,072 KB
testcase_17 AC 402 ms
78,620 KB
testcase_18 AC 628 ms
78,516 KB
testcase_19 AC 573 ms
78,404 KB
testcase_20 AC 459 ms
78,228 KB
testcase_21 AC 523 ms
78,572 KB
testcase_22 AC 115 ms
77,344 KB
testcase_23 AC 295 ms
78,068 KB
testcase_24 AC 92 ms
76,332 KB
testcase_25 AC 88 ms
76,352 KB
testcase_26 AC 82 ms
76,220 KB
testcase_27 AC 88 ms
76,332 KB
testcase_28 AC 91 ms
76,420 KB
testcase_29 AC 437 ms
78,460 KB
testcase_30 AC 502 ms
78,488 KB
testcase_31 AC 76 ms
71,668 KB
testcase_32 AC 76 ms
71,436 KB
testcase_33 AC 82 ms
76,428 KB
testcase_34 AC 443 ms
78,508 KB
testcase_35 AC 282 ms
78,296 KB
testcase_36 AC 511 ms
78,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,V,C = map(int, input().split())
VW = [list(map(int, input().split())) for _ in range(N)]
if not (1<=N<=5000 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