結果

問題 No.2429 Happiest Tabehodai Ways
ユーザー noriocnorioc
提出日時 2023-08-19 00:02:35
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 835 bytes
コンパイル時間 771 ms
コンパイル使用メモリ 87,036 KB
実行使用メモリ 78,844 KB
最終ジャッジ日時 2023-08-19 10:46:22
合計ジャッジ時間 7,463 ms
ジャッジサーバーID
(参考情報)
judge9 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
72,564 KB
testcase_01 RE -
testcase_02 AC 112 ms
72,236 KB
testcase_03 AC 109 ms
72,348 KB
testcase_04 AC 109 ms
72,228 KB
testcase_05 AC 108 ms
72,496 KB
testcase_06 AC 108 ms
72,264 KB
testcase_07 AC 109 ms
72,344 KB
testcase_08 AC 110 ms
76,940 KB
testcase_09 AC 108 ms
76,528 KB
testcase_10 AC 113 ms
76,788 KB
testcase_11 AC 116 ms
76,676 KB
testcase_12 AC 118 ms
77,388 KB
testcase_13 AC 123 ms
77,740 KB
testcase_14 AC 138 ms
77,392 KB
testcase_15 AC 111 ms
76,972 KB
testcase_16 RE -
testcase_17 AC 124 ms
77,672 KB
testcase_18 AC 125 ms
77,420 KB
testcase_19 AC 119 ms
77,040 KB
testcase_20 AC 107 ms
72,468 KB
testcase_21 AC 110 ms
72,268 KB
testcase_22 AC 107 ms
72,360 KB
testcase_23 AC 109 ms
72,168 KB
testcase_24 AC 113 ms
76,596 KB
testcase_25 AC 117 ms
76,456 KB
testcase_26 AC 109 ms
76,540 KB
testcase_27 AC 107 ms
72,568 KB
testcase_28 AC 123 ms
77,048 KB
testcase_29 AC 121 ms
77,788 KB
testcase_30 AC 114 ms
76,824 KB
testcase_31 AC 116 ms
77,608 KB
testcase_32 AC 130 ms
77,456 KB
testcase_33 AC 122 ms
77,420 KB
testcase_34 AC 117 ms
77,564 KB
testcase_35 AC 125 ms
77,600 KB
testcase_36 AC 122 ms
77,156 KB
testcase_37 AC 115 ms
77,428 KB
testcase_38 AC 112 ms
72,236 KB
testcase_39 AC 123 ms
77,464 KB
testcase_40 AC 116 ms
77,592 KB
testcase_41 AC 131 ms
77,668 KB
testcase_42 AC 105 ms
72,168 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 1
    return m, cnt


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