結果

問題 No.2429 Happiest Tabehodai Ways
ユーザー chineristACchineristAC
提出日時 2023-08-18 21:58:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 651 bytes
コンパイル時間 322 ms
コンパイル使用メモリ 86,984 KB
実行使用メモリ 77,020 KB
最終ジャッジ日時 2023-09-03 03:03:35
合計ジャッジ時間 5,746 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
76,840 KB
testcase_01 AC 81 ms
71,528 KB
testcase_02 AC 75 ms
71,244 KB
testcase_03 AC 79 ms
71,492 KB
testcase_04 AC 78 ms
71,260 KB
testcase_05 AC 79 ms
71,276 KB
testcase_06 AC 77 ms
71,532 KB
testcase_07 AC 77 ms
71,532 KB
testcase_08 AC 77 ms
71,460 KB
testcase_09 AC 81 ms
75,984 KB
testcase_10 AC 80 ms
75,852 KB
testcase_11 AC 86 ms
75,932 KB
testcase_12 AC 84 ms
76,024 KB
testcase_13 AC 87 ms
76,692 KB
testcase_14 AC 86 ms
76,712 KB
testcase_15 AC 94 ms
76,844 KB
testcase_16 AC 84 ms
76,368 KB
testcase_17 AC 82 ms
75,768 KB
testcase_18 AC 88 ms
76,736 KB
testcase_19 AC 89 ms
76,412 KB
testcase_20 AC 89 ms
76,548 KB
testcase_21 AC 77 ms
71,276 KB
testcase_22 AC 77 ms
71,412 KB
testcase_23 AC 76 ms
71,448 KB
testcase_24 AC 76 ms
71,456 KB
testcase_25 AC 85 ms
76,196 KB
testcase_26 AC 89 ms
76,124 KB
testcase_27 AC 85 ms
75,880 KB
testcase_28 AC 80 ms
71,288 KB
testcase_29 AC 93 ms
76,700 KB
testcase_30 AC 91 ms
76,716 KB
testcase_31 AC 85 ms
76,272 KB
testcase_32 AC 85 ms
76,848 KB
testcase_33 AC 92 ms
76,684 KB
testcase_34 AC 92 ms
76,856 KB
testcase_35 AC 86 ms
76,864 KB
testcase_36 AC 95 ms
76,832 KB
testcase_37 AC 88 ms
77,020 KB
testcase_38 AC 87 ms
76,784 KB
testcase_39 AC 79 ms
71,172 KB
testcase_40 AC 98 ms
76,664 KB
testcase_41 AC 88 ms
76,752 KB
testcase_42 AC 101 ms
76,856 KB
testcase_43 AC 77 ms
71,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from itertools import permutations
import heapq

input = lambda :sys.stdin.readline().rstrip()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

mod = 998244353

N,K = mi()
C = li()
D = li()

dp_happy = [0] * (K+1)
dp_way = [1] * (K+1)

for k in range(1,K+1):
    for i in range(N):
        if C[i] <= k:
            if D[i] + dp_happy[k-C[i]] > dp_happy[k]:
                dp_happy[k] = D[i] + dp_happy[k-C[i]]
                dp_way[k] = dp_way[k-C[i]]
            elif D[i] + dp_happy[k-C[i]] == dp_happy[k]:
                dp_way[k] += dp_way[k-C[i]]
                dp_way[k] %= mod

print(dp_happy[K])
print(dp_way[K])
0