結果

問題 No.2429 Happiest Tabehodai Ways
ユーザー tassei903tassei903
提出日時 2023-08-11 20:40:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 796 bytes
コンパイル時間 454 ms
コンパイル使用メモリ 87,308 KB
実行使用メモリ 77,984 KB
最終ジャッジ日時 2023-09-03 03:02:03
合計ジャッジ時間 6,448 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
76,940 KB
testcase_01 AC 77 ms
71,448 KB
testcase_02 AC 72 ms
71,404 KB
testcase_03 AC 79 ms
76,472 KB
testcase_04 AC 74 ms
71,460 KB
testcase_05 AC 72 ms
71,444 KB
testcase_06 AC 71 ms
71,288 KB
testcase_07 AC 70 ms
71,144 KB
testcase_08 AC 72 ms
71,628 KB
testcase_09 AC 83 ms
76,872 KB
testcase_10 AC 71 ms
71,160 KB
testcase_11 AC 93 ms
76,884 KB
testcase_12 AC 92 ms
77,016 KB
testcase_13 AC 115 ms
77,984 KB
testcase_14 AC 116 ms
77,740 KB
testcase_15 AC 138 ms
77,868 KB
testcase_16 AC 100 ms
77,012 KB
testcase_17 AC 85 ms
76,596 KB
testcase_18 AC 117 ms
77,820 KB
testcase_19 AC 122 ms
77,536 KB
testcase_20 AC 117 ms
77,456 KB
testcase_21 AC 72 ms
71,512 KB
testcase_22 AC 74 ms
71,672 KB
testcase_23 AC 73 ms
71,464 KB
testcase_24 AC 70 ms
71,356 KB
testcase_25 AC 81 ms
76,764 KB
testcase_26 AC 82 ms
76,840 KB
testcase_27 AC 76 ms
71,660 KB
testcase_28 AC 72 ms
71,392 KB
testcase_29 AC 96 ms
76,828 KB
testcase_30 AC 110 ms
77,800 KB
testcase_31 AC 90 ms
76,952 KB
testcase_32 AC 89 ms
77,260 KB
testcase_33 AC 104 ms
76,684 KB
testcase_34 AC 99 ms
77,176 KB
testcase_35 AC 98 ms
77,156 KB
testcase_36 AC 97 ms
76,980 KB
testcase_37 AC 105 ms
77,232 KB
testcase_38 AC 106 ms
76,916 KB
testcase_39 AC 94 ms
76,660 KB
testcase_40 AC 99 ms
77,080 KB
testcase_41 AC 123 ms
77,764 KB
testcase_42 AC 96 ms
76,980 KB
testcase_43 AC 83 ms
71,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
c = list(map(int, input().split()))
d = list(map(int, input().split()))
inf = float("inf")
fv = [-inf for i in range(k+1)]
fw = [0 for i in range(k+1)]

for i in range(n):
    if c[i] <= k:
        fv[c[i]] = max(fv[c[i]], d[i])

for i in range(n):
    if c[i] <= k and fv[c[i]] == d[i]:
        fw[c[i]] += 1

dpv = [-inf] * (k+1)
dpw = [0] * (k+1)
dpv[0] = 0
dpw[0] = 1
mod = 998244353

for i in range(1, k+1):
    for j in range(1, i+1):
        dpv[i] = max(dpv[i], dpv[i-j] + fv[j])
    for j in range(1, i+1):
        if dpv[i] == fv[j] + dpv[i-j]:
            dpw[i] += dpw[i-j] * fw[j] % mod
            dpw[i] %= mod

ansv = max(dpv)
print(ansv)
answ = 0
for i in range(k+1):
    if dpv[i] == ansv:
        answ += dpw[i]
        answ %= mod

print(answ)
0