結果

問題 No.2429 Happiest Tabehodai Ways
ユーザー rlangevinrlangevin
提出日時 2023-09-18 15:36:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 695 bytes
コンパイル時間 1,004 ms
コンパイル使用メモリ 86,936 KB
実行使用メモリ 76,736 KB
最終ジャッジ日時 2023-09-18 15:36:51
合計ジャッジ時間 6,606 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 100 ms
76,692 KB
testcase_01 AC 83 ms
76,380 KB
testcase_02 AC 80 ms
76,264 KB
testcase_03 AC 80 ms
76,276 KB
testcase_04 AC 83 ms
76,480 KB
testcase_05 AC 78 ms
71,236 KB
testcase_06 AC 79 ms
76,120 KB
testcase_07 AC 79 ms
76,240 KB
testcase_08 AC 82 ms
76,304 KB
testcase_09 AC 84 ms
76,316 KB
testcase_10 AC 86 ms
76,316 KB
testcase_11 AC 85 ms
76,456 KB
testcase_12 AC 86 ms
76,356 KB
testcase_13 AC 93 ms
76,544 KB
testcase_14 AC 92 ms
76,676 KB
testcase_15 AC 94 ms
76,596 KB
testcase_16 AC 85 ms
76,356 KB
testcase_17 AC 86 ms
76,344 KB
testcase_18 AC 90 ms
76,668 KB
testcase_19 AC 88 ms
76,320 KB
testcase_20 AC 91 ms
76,132 KB
testcase_21 AC 79 ms
76,272 KB
testcase_22 AC 81 ms
76,232 KB
testcase_23 AC 84 ms
76,456 KB
testcase_24 AC 85 ms
76,376 KB
testcase_25 AC 87 ms
76,376 KB
testcase_26 AC 86 ms
76,516 KB
testcase_27 AC 84 ms
76,088 KB
testcase_28 AC 84 ms
76,328 KB
testcase_29 AC 88 ms
76,300 KB
testcase_30 AC 91 ms
76,604 KB
testcase_31 AC 90 ms
76,244 KB
testcase_32 AC 98 ms
76,668 KB
testcase_33 AC 90 ms
76,452 KB
testcase_34 AC 92 ms
76,572 KB
testcase_35 AC 92 ms
76,540 KB
testcase_36 AC 96 ms
76,704 KB
testcase_37 AC 83 ms
76,340 KB
testcase_38 AC 90 ms
76,736 KB
testcase_39 AC 74 ms
71,448 KB
testcase_40 AC 90 ms
76,532 KB
testcase_41 AC 84 ms
76,436 KB
testcase_42 AC 99 ms
76,672 KB
testcase_43 AC 82 ms
71,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())
C = list(map(int, input().split()))
D = list(map(int, input().split()))
M = 1005
inf = 10 ** 18
mod = 998244353
dp = [-inf] * M
dp_n = [0] * M
dp[0] = 0
dp_n[0] = 1

for i in range(M):
    for c, d in zip(C, D):
        if i - c >= 0:
            if dp[i - c] + d > dp[i]:
                dp[i] = dp[i - c] + d
                dp_n[i] = dp_n[i - c]
            elif dp[i - c] + d == dp[i]:
                dp_n[i] += dp_n[i - c]
                dp_n[i] %= mod
    
ans = -1
num = 0
for i in range(K + 1):
    if dp[i] > ans:
        ans = dp[i]
        num = dp_n[i]
    elif dp[i] == ans:
        num += dp_n[i]
        num %= mod
        
print(ans)
print(num)
0