結果

問題 No.1947 質より種類数
ユーザー neko0774neko0774
提出日時 2022-05-20 22:12:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 593 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 12,004 KB
実行使用メモリ 15,156 KB
最終ジャッジ日時 2023-10-20 12:54:36
合計ジャッジ時間 6,776 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,008 KB
testcase_01 AC 34 ms
10,008 KB
testcase_02 AC 34 ms
10,008 KB
testcase_03 AC 31 ms
10,008 KB
testcase_04 AC 113 ms
10,184 KB
testcase_05 AC 85 ms
10,200 KB
testcase_06 AC 89 ms
10,168 KB
testcase_07 AC 100 ms
10,200 KB
testcase_08 AC 113 ms
10,180 KB
testcase_09 AC 382 ms
10,224 KB
testcase_10 AC 280 ms
10,212 KB
testcase_11 AC 839 ms
10,252 KB
testcase_12 AC 582 ms
10,236 KB
testcase_13 AC 228 ms
10,208 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

inf=10**18
dxy=[(0,1), (1,0), (-1, 0), (0, -1)]
mod=10**9+7
MOD=998244353

def main():
    N, V, C = map(int, input().split())
    dp = [0]*(V+1)
    fvw = []
    VW = []
    for _ in range(N):
        v, w = map(int, input().split())
        fvw.append([v, w+C])
        VW.append([v, w])
    
    for i in range(N):
        v, w = fvw[i]
        for p in range(v, V+1)[::-1]: 
            dp[p] = max(dp[p], dp[p-v]+w)
    for i in range(N):
        v, w = VW[i]
        for p in range(V+1):
            if p+v<V+1: dp[p+v] = max(dp[p+v], dp[p]+w)
    print(max(dp))
                

main()
0