結果

問題 No.2429 Happiest Tabehodai Ways
ユーザー noriocnorioc
提出日時 2023-08-19 00:02:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 838 bytes
コンパイル時間 437 ms
コンパイル使用メモリ 87,272 KB
実行使用メモリ 77,784 KB
最終ジャッジ日時 2023-09-03 03:05:14
合計ジャッジ時間 7,041 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
77,408 KB
testcase_01 AC 106 ms
72,504 KB
testcase_02 AC 105 ms
72,312 KB
testcase_03 AC 105 ms
72,264 KB
testcase_04 AC 105 ms
72,316 KB
testcase_05 AC 104 ms
72,396 KB
testcase_06 AC 104 ms
72,316 KB
testcase_07 AC 105 ms
72,320 KB
testcase_08 AC 105 ms
72,516 KB
testcase_09 AC 106 ms
76,788 KB
testcase_10 AC 106 ms
76,492 KB
testcase_11 AC 110 ms
76,872 KB
testcase_12 AC 113 ms
76,728 KB
testcase_13 AC 115 ms
77,568 KB
testcase_14 AC 121 ms
77,680 KB
testcase_15 AC 133 ms
77,668 KB
testcase_16 AC 110 ms
77,308 KB
testcase_17 AC 110 ms
76,428 KB
testcase_18 AC 118 ms
77,784 KB
testcase_19 AC 120 ms
77,192 KB
testcase_20 AC 115 ms
77,184 KB
testcase_21 AC 103 ms
72,476 KB
testcase_22 AC 104 ms
72,304 KB
testcase_23 AC 102 ms
72,348 KB
testcase_24 AC 102 ms
72,300 KB
testcase_25 AC 109 ms
76,476 KB
testcase_26 AC 110 ms
76,580 KB
testcase_27 AC 105 ms
76,596 KB
testcase_28 AC 102 ms
72,356 KB
testcase_29 AC 116 ms
77,332 KB
testcase_30 AC 118 ms
77,580 KB
testcase_31 AC 109 ms
76,892 KB
testcase_32 AC 111 ms
77,440 KB
testcase_33 AC 123 ms
77,164 KB
testcase_34 AC 119 ms
77,784 KB
testcase_35 AC 118 ms
77,412 KB
testcase_36 AC 122 ms
77,656 KB
testcase_37 AC 115 ms
77,580 KB
testcase_38 AC 113 ms
77,324 KB
testcase_39 AC 107 ms
72,516 KB
testcase_40 AC 122 ms
77,700 KB
testcase_41 AC 113 ms
77,228 KB
testcase_42 AC 129 ms
77,708 KB
testcase_43 AC 104 ms
72,460 KB
権限があれば一括ダウンロードができます

ソースコード

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)
    pp = [0] * (K+1)
    pp[0] = 1
    for i in range(K):
        for j in range(N):
            c = C[j]
            d = D[j]
            if i+c > K: continue
            if dp[i+c] == dp[i] + d:
                pp[i+c] += pp[i]
                pp[i+c] %= MOD
            elif dp[i+c] < dp[i] + d:
                dp[i+c] = dp[i] + d
                pp[i+c] = pp[i]

    m = 0
    cnt = 0
    for k in range(K+1):
        if m == dp[k]:
            cnt += pp[k]
        elif m < dp[k]:
            m = dp[k]
            cnt = pp[k]

    if m == 0: return 0, 1
    return m, cnt


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