結果

問題 No.1947 質より種類数
ユーザー roarisroaris
提出日時 2022-05-20 21:58:18
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 738 ms / 2,000 ms
コード長 517 bytes
コンパイル時間 204 ms
コンパイル使用メモリ 81,760 KB
実行使用メモリ 76,364 KB
最終ジャッジ日時 2023-10-20 12:34:15
合計ジャッジ時間 8,691 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
53,340 KB
testcase_01 AC 42 ms
53,328 KB
testcase_02 AC 42 ms
53,344 KB
testcase_03 AC 41 ms
53,304 KB
testcase_04 AC 63 ms
66,272 KB
testcase_05 AC 63 ms
65,764 KB
testcase_06 AC 64 ms
66,856 KB
testcase_07 AC 61 ms
66,076 KB
testcase_08 AC 65 ms
66,228 KB
testcase_09 AC 77 ms
67,172 KB
testcase_10 AC 72 ms
66,976 KB
testcase_11 AC 93 ms
68,472 KB
testcase_12 AC 78 ms
67,272 KB
testcase_13 AC 68 ms
66,044 KB
testcase_14 AC 192 ms
72,044 KB
testcase_15 AC 135 ms
69,592 KB
testcase_16 AC 255 ms
73,136 KB
testcase_17 AC 323 ms
73,020 KB
testcase_18 AC 738 ms
76,364 KB
testcase_19 AC 478 ms
74,196 KB
testcase_20 AC 367 ms
72,744 KB
testcase_21 AC 552 ms
73,508 KB
testcase_22 AC 82 ms
67,920 KB
testcase_23 AC 215 ms
71,680 KB
testcase_24 AC 62 ms
65,740 KB
testcase_25 AC 63 ms
65,624 KB
testcase_26 AC 57 ms
64,488 KB
testcase_27 AC 59 ms
65,040 KB
testcase_28 AC 66 ms
66,892 KB
testcase_29 AC 458 ms
73,836 KB
testcase_30 AC 436 ms
72,252 KB
testcase_31 AC 42 ms
53,304 KB
testcase_32 AC 43 ms
53,308 KB
testcase_33 AC 53 ms
62,780 KB
testcase_34 AC 696 ms
74,036 KB
testcase_35 AC 319 ms
69,484 KB
testcase_36 AC 412 ms
72,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import *

N, V, C = map(int, input().split())
vw = [tuple(map(int, input().split())) for _ in range(N)]
dp1 = [0]*(V+1)

for i in range(N):
    v, w = vw[i]
    
    for j in range(V, -1, -1):
        if j-v>=0:
            dp1[j] = max(dp1[j], dp1[j-v]+w+C)

dp2 = [0]*(V+1)

for i in range(V+1):
    for v, w in vw:
        if i+v<=V:
            dp2[i+v] = max(dp2[i+v], dp2[i]+w)

ans = 0

for i in range(V+1):
    ans = max(ans, dp1[i]+dp2[V-i])

print(ans)
0