結果

問題 No.2429 Happiest Tabehodai Ways
ユーザー noriocnorioc
提出日時 2023-08-18 23:53:45
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 760 bytes
コンパイル時間 447 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 77,752 KB
最終ジャッジ日時 2023-08-19 10:46:19
合計ジャッジ時間 6,989 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
72,692 KB
testcase_01 AC 103 ms
72,464 KB
testcase_02 AC 107 ms
72,512 KB
testcase_03 AC 106 ms
72,420 KB
testcase_04 AC 108 ms
72,408 KB
testcase_05 AC 106 ms
72,388 KB
testcase_06 AC 104 ms
72,532 KB
testcase_07 AC 101 ms
72,568 KB
testcase_08 AC 108 ms
76,988 KB
testcase_09 AC 107 ms
76,492 KB
testcase_10 AC 110 ms
76,780 KB
testcase_11 AC 111 ms
76,628 KB
testcase_12 AC 116 ms
77,528 KB
testcase_13 AC 117 ms
77,620 KB
testcase_14 AC 129 ms
77,684 KB
testcase_15 AC 111 ms
77,316 KB
testcase_16 AC 107 ms
76,588 KB
testcase_17 AC 115 ms
77,508 KB
testcase_18 AC 121 ms
77,604 KB
testcase_19 AC 115 ms
77,072 KB
testcase_20 WA -
testcase_21 AC 110 ms
72,336 KB
testcase_22 AC 105 ms
72,328 KB
testcase_23 AC 107 ms
72,328 KB
testcase_24 AC 115 ms
76,616 KB
testcase_25 AC 115 ms
76,744 KB
testcase_26 AC 110 ms
76,544 KB
testcase_27 AC 109 ms
72,696 KB
testcase_28 AC 122 ms
77,216 KB
testcase_29 AC 117 ms
77,600 KB
testcase_30 AC 110 ms
76,924 KB
testcase_31 AC 115 ms
77,632 KB
testcase_32 AC 132 ms
77,484 KB
testcase_33 AC 122 ms
77,752 KB
testcase_34 AC 122 ms
77,540 KB
testcase_35 AC 133 ms
77,480 KB
testcase_36 AC 112 ms
77,520 KB
testcase_37 AC 114 ms
77,424 KB
testcase_38 AC 109 ms
72,452 KB
testcase_39 AC 128 ms
77,440 KB
testcase_40 AC 112 ms
77,312 KB
testcase_41 AC 127 ms
77,596 KB
testcase_42 AC 106 ms
72,332 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 = 1
    for k in range(K+1):
        if m < dp[k]:
            m = dp[k]
            cnt = pp[k]
    return m, cnt


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