結果

問題 No.2429 Happiest Tabehodai Ways
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2023-08-18 21:52:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 755 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 82,100 KB
実行使用メモリ 76,084 KB
最終ジャッジ日時 2024-05-06 17:58:50
合計ジャッジ時間 3,523 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
62,392 KB
testcase_01 AC 35 ms
52,392 KB
testcase_02 AC 34 ms
53,096 KB
testcase_03 AC 34 ms
52,364 KB
testcase_04 AC 33 ms
52,896 KB
testcase_05 AC 35 ms
52,392 KB
testcase_06 AC 33 ms
52,796 KB
testcase_07 AC 34 ms
52,628 KB
testcase_08 AC 34 ms
52,276 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 50 ms
65,968 KB
testcase_14 WA -
testcase_15 AC 82 ms
76,084 KB
testcase_16 WA -
testcase_17 AC 36 ms
58,988 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 51 ms
66,236 KB
testcase_21 WA -
testcase_22 AC 31 ms
52,864 KB
testcase_23 AC 33 ms
53,020 KB
testcase_24 AC 34 ms
52,572 KB
testcase_25 AC 41 ms
60,120 KB
testcase_26 AC 41 ms
60,652 KB
testcase_27 AC 38 ms
59,208 KB
testcase_28 AC 33 ms
53,012 KB
testcase_29 AC 52 ms
64,288 KB
testcase_30 AC 54 ms
68,048 KB
testcase_31 AC 41 ms
61,224 KB
testcase_32 AC 40 ms
62,308 KB
testcase_33 AC 65 ms
70,896 KB
testcase_34 AC 54 ms
68,132 KB
testcase_35 AC 45 ms
63,460 KB
testcase_36 AC 57 ms
66,824 KB
testcase_37 AC 43 ms
60,712 KB
testcase_38 AC 45 ms
62,068 KB
testcase_39 AC 35 ms
53,476 KB
testcase_40 AC 53 ms
62,316 KB
testcase_41 AC 49 ms
63,948 KB
testcase_42 AC 66 ms
65,556 KB
testcase_43 AC 33 ms
52,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

ナップザック

dp[]

"""

import sys
from sys import stdin

N,K = map(int,stdin.readline().split())

C = list(map(int,stdin.readline().split()))
D = list(map(int,stdin.readline().split()))

mod = 998244353

dpmax = [float("-inf")] * (K+1)
dpcnt = [0] * (K+1)

dpmax[0] = 0
dpcnt[0] = 1

for csum in range(K):

    for c,d in zip(C,D):

        if csum+c <= K:

            nexd = dpmax[csum] + d
            if nexd > dpmax[csum+c]:
                dpmax[csum+c] = nexd
                dpcnt[csum+c] = 0

            if nexd == dpmax[csum+c]:
                dpcnt[csum+c] += dpcnt[csum]
                dpcnt[csum+c] %= mod

for i in range(K,-1,-1):

    if dpmax[i] >= 0:
        print (dpmax[i])
        print (dpcnt[i] % mod)
        break
0