結果

問題 No.1947 質より種類数
ユーザー lilictakalilictaka
提出日時 2022-05-21 00:41:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 716 ms / 2,000 ms
コード長 349 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 81,812 KB
実行使用メモリ 78,012 KB
最終ジャッジ日時 2023-10-20 15:18:54
合計ジャッジ時間 8,832 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
53,484 KB
testcase_01 AC 34 ms
53,484 KB
testcase_02 AC 34 ms
53,484 KB
testcase_03 AC 34 ms
53,484 KB
testcase_04 AC 73 ms
72,620 KB
testcase_05 AC 59 ms
70,564 KB
testcase_06 AC 64 ms
73,148 KB
testcase_07 AC 59 ms
70,552 KB
testcase_08 AC 66 ms
73,148 KB
testcase_09 AC 84 ms
75,668 KB
testcase_10 AC 85 ms
75,684 KB
testcase_11 AC 118 ms
76,412 KB
testcase_12 AC 96 ms
75,668 KB
testcase_13 AC 77 ms
75,668 KB
testcase_14 AC 286 ms
76,748 KB
testcase_15 AC 157 ms
76,624 KB
testcase_16 AC 341 ms
77,064 KB
testcase_17 AC 394 ms
77,272 KB
testcase_18 AC 716 ms
78,012 KB
testcase_19 AC 613 ms
77,760 KB
testcase_20 AC 429 ms
77,372 KB
testcase_21 AC 674 ms
77,480 KB
testcase_22 AC 104 ms
75,680 KB
testcase_23 AC 284 ms
76,836 KB
testcase_24 AC 71 ms
72,624 KB
testcase_25 AC 64 ms
70,552 KB
testcase_26 AC 59 ms
68,492 KB
testcase_27 AC 61 ms
70,556 KB
testcase_28 AC 67 ms
73,144 KB
testcase_29 AC 495 ms
77,760 KB
testcase_30 AC 389 ms
77,692 KB
testcase_31 AC 36 ms
53,484 KB
testcase_32 AC 36 ms
53,484 KB
testcase_33 AC 45 ms
62,244 KB
testcase_34 AC 410 ms
77,812 KB
testcase_35 AC 254 ms
77,704 KB
testcase_36 AC 389 ms
77,808 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