結果

問題 No.1947 質より種類数
ユーザー lllllll88938494lllllll88938494
提出日時 2022-09-10 19:01:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,051 ms / 2,000 ms
コード長 428 bytes
コンパイル時間 1,069 ms
コンパイル使用メモリ 86,784 KB
実行使用メモリ 274,132 KB
最終ジャッジ日時 2023-08-18 01:05:17
合計ジャッジ時間 15,583 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,272 KB
testcase_01 AC 72 ms
71,556 KB
testcase_02 AC 73 ms
71,180 KB
testcase_03 AC 72 ms
71,232 KB
testcase_04 AC 99 ms
76,168 KB
testcase_05 AC 95 ms
76,244 KB
testcase_06 AC 97 ms
76,232 KB
testcase_07 AC 97 ms
75,988 KB
testcase_08 AC 102 ms
76,604 KB
testcase_09 AC 123 ms
81,168 KB
testcase_10 AC 113 ms
76,176 KB
testcase_11 AC 169 ms
87,608 KB
testcase_12 AC 134 ms
83,580 KB
testcase_13 AC 107 ms
76,860 KB
testcase_14 AC 394 ms
132,532 KB
testcase_15 AC 261 ms
105,380 KB
testcase_16 AC 564 ms
157,540 KB
testcase_17 AC 704 ms
181,460 KB
testcase_18 AC 1,051 ms
261,896 KB
testcase_19 AC 917 ms
239,288 KB
testcase_20 AC 704 ms
199,256 KB
testcase_21 AC 877 ms
220,992 KB
testcase_22 AC 134 ms
85,028 KB
testcase_23 AC 423 ms
138,432 KB
testcase_24 AC 97 ms
76,172 KB
testcase_25 AC 97 ms
76,156 KB
testcase_26 AC 91 ms
76,204 KB
testcase_27 AC 95 ms
76,812 KB
testcase_28 AC 99 ms
76,572 KB
testcase_29 AC 898 ms
274,020 KB
testcase_30 AC 825 ms
273,792 KB
testcase_31 AC 72 ms
70,956 KB
testcase_32 AC 71 ms
71,296 KB
testcase_33 AC 83 ms
76,032 KB
testcase_34 AC 668 ms
273,748 KB
testcase_35 AC 372 ms
274,132 KB
testcase_36 AC 812 ms
273,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,V,C=map(int,input().split())

dp=[[-1]*(V+1) for i in range(N+1)]
dp[0][0] = 0

for i in range(N):
    v,w=map(int,input().split())
    for j in range(V+1):
        if dp[i][j] == -1:
            continue
        if j + v <= V:
            dp[i][j+v] = max(dp[i][j+v],dp[i][j] + w)
            dp[i+1][j+v] = max(dp[i][j] + w + C , dp[i+1][j+v])
        dp[i+1][j] = max(dp[i][j],dp[i+1][j]) 
        
print(max(dp[-1]))

    
0