結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
63,580 KB
testcase_01 AC 37 ms
52,636 KB
testcase_02 AC 34 ms
52,736 KB
testcase_03 AC 34 ms
52,580 KB
testcase_04 AC 32 ms
52,976 KB
testcase_05 AC 32 ms
52,376 KB
testcase_06 AC 32 ms
52,208 KB
testcase_07 AC 32 ms
53,460 KB
testcase_08 AC 32 ms
52,424 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 51 ms
67,532 KB
testcase_14 WA -
testcase_15 AC 86 ms
75,868 KB
testcase_16 WA -
testcase_17 AC 36 ms
57,892 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 53 ms
66,940 KB
testcase_21 WA -
testcase_22 AC 34 ms
52,892 KB
testcase_23 AC 32 ms
52,588 KB
testcase_24 AC 34 ms
53,096 KB
testcase_25 AC 40 ms
60,232 KB
testcase_26 AC 40 ms
62,320 KB
testcase_27 AC 37 ms
58,492 KB
testcase_28 AC 34 ms
53,612 KB
testcase_29 AC 48 ms
63,824 KB
testcase_30 AC 52 ms
67,404 KB
testcase_31 AC 39 ms
61,728 KB
testcase_32 AC 41 ms
62,588 KB
testcase_33 AC 65 ms
70,752 KB
testcase_34 AC 55 ms
67,288 KB
testcase_35 AC 45 ms
64,628 KB
testcase_36 AC 58 ms
65,680 KB
testcase_37 AC 45 ms
60,728 KB
testcase_38 AC 44 ms
62,912 KB
testcase_39 AC 36 ms
53,036 KB
testcase_40 AC 56 ms
63,072 KB
testcase_41 AC 48 ms
65,300 KB
testcase_42 AC 66 ms
65,776 KB
testcase_43 AC 33 ms
52,684 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()))

assert 1 <= N <= 1000
assert 1 <= K <= 1000
for i in range(N):
    assert 1 <= C[i] <= 1000
    assert 1 <= D[i] <= 1000
 
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