結果

問題 No.2429 Happiest Tabehodai Ways
ユーザー noriocnorioc
提出日時 2023-08-18 23:44:59
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 901 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 86,944 KB
実行使用メモリ 164,616 KB
最終ジャッジ日時 2023-08-19 10:46:14
合計ジャッジ時間 5,929 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
76,616 KB
testcase_01 AC 91 ms
72,152 KB
testcase_02 AC 91 ms
72,436 KB
testcase_03 AC 92 ms
72,240 KB
testcase_04 AC 97 ms
72,264 KB
testcase_05 AC 90 ms
72,200 KB
testcase_06 AC 92 ms
72,308 KB
testcase_07 AC 92 ms
72,420 KB
testcase_08 AC 97 ms
76,840 KB
testcase_09 AC 92 ms
76,412 KB
testcase_10 AC 132 ms
79,072 KB
testcase_11 AC 113 ms
77,472 KB
testcase_12 AC 189 ms
82,144 KB
testcase_13 AC 123 ms
77,528 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 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import cache
import sys
sys.setrecursionlimit(10 ** 6)

MOD = 998244353
N, K = map(int, input().split())
C = list(map(int, input().split()))
D = list(map(int, input().split()))


def f():
    dp = [0] * (K+1)
    for i in range(K):
        for j in range(N):
            c = C[j]
            d = D[j]
            if i+c > K: continue
            dp[i+c] = max(dp[i+c], dp[i] + d)

    m = 0
    kk = 0
    for k in range(K+1):
        if m < dp[k]:
            m = dp[k]
            kk = k
    return m, kk


# @cache

memo = {}
def g(h, k):
    if k == 0:
        if h > 0: return 0
        return 1

    if (h, k) in memo: return memo[h, k]

    res = 0
    for i in range(N):
        c = C[i]
        d = D[i]
        if h - d < 0 or k - c < 0: continue
        res += g(h-d, k-c)
        res %= MOD
    memo[h, k] = res
    return res


h, k = f()
cnt = g(h, k)
print(h)
print(cnt)
0