結果

問題 No.1947 質より種類数
ユーザー lilictakalilictaka
提出日時 2022-05-21 00:41:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 783 ms / 2,000 ms
コード長 349 bytes
コンパイル時間 229 ms
コンパイル使用メモリ 82,376 KB
実行使用メモリ 78,784 KB
最終ジャッジ日時 2024-09-20 10:50:22
合計ジャッジ時間 9,374 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
51,712 KB
testcase_01 AC 38 ms
51,840 KB
testcase_02 AC 37 ms
51,968 KB
testcase_03 AC 37 ms
52,224 KB
testcase_04 AC 75 ms
71,424 KB
testcase_05 AC 71 ms
70,144 KB
testcase_06 AC 71 ms
72,320 KB
testcase_07 AC 71 ms
70,528 KB
testcase_08 AC 71 ms
72,832 KB
testcase_09 AC 92 ms
76,032 KB
testcase_10 AC 92 ms
76,032 KB
testcase_11 AC 129 ms
76,656 KB
testcase_12 AC 103 ms
76,032 KB
testcase_13 AC 83 ms
76,160 KB
testcase_14 AC 313 ms
77,440 KB
testcase_15 AC 177 ms
77,076 KB
testcase_16 AC 369 ms
77,644 KB
testcase_17 AC 430 ms
77,508 KB
testcase_18 AC 783 ms
78,784 KB
testcase_19 AC 682 ms
78,316 KB
testcase_20 AC 470 ms
77,880 KB
testcase_21 AC 746 ms
77,712 KB
testcase_22 AC 109 ms
76,156 KB
testcase_23 AC 297 ms
77,232 KB
testcase_24 AC 71 ms
73,088 KB
testcase_25 AC 69 ms
70,784 KB
testcase_26 AC 62 ms
68,352 KB
testcase_27 AC 66 ms
69,760 KB
testcase_28 AC 71 ms
72,320 KB
testcase_29 AC 504 ms
78,208 KB
testcase_30 AC 403 ms
78,464 KB
testcase_31 AC 38 ms
51,712 KB
testcase_32 AC 38 ms
51,968 KB
testcase_33 AC 47 ms
61,056 KB
testcase_34 AC 417 ms
78,256 KB
testcase_35 AC 256 ms
78,336 KB
testcase_36 AC 407 ms
78,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,V,C = map(int,input().split())
INF = float('inf')
dp = [-INF] * (V+1)
dp[0] = 0
for _ in range(N):
    ndp = [-INF] * (V+1)
    vi,wi = map(int,input().split())
    for v  in range(V+1):
        if v - vi >= 0:
            ndp[v] = max(dp[v-vi] + C+wi,ndp[v-vi] + wi,ndp[v])
        ndp[v] = max(dp[v],ndp[v])
    dp = ndp
print(max(ndp))




    
0