結果

問題 No.2429 Happiest Tabehodai Ways
ユーザー titiatitia
提出日時 2023-09-05 00:23:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 349 ms / 2,000 ms
コード長 678 bytes
コンパイル時間 327 ms
コンパイル使用メモリ 87,160 KB
実行使用メモリ 78,068 KB
最終ジャッジ日時 2023-09-05 00:23:14
合計ジャッジ時間 7,622 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
78,068 KB
testcase_01 AC 73 ms
71,452 KB
testcase_02 AC 73 ms
71,272 KB
testcase_03 AC 73 ms
71,300 KB
testcase_04 AC 72 ms
71,444 KB
testcase_05 AC 72 ms
71,624 KB
testcase_06 AC 73 ms
71,480 KB
testcase_07 AC 104 ms
71,520 KB
testcase_08 AC 76 ms
71,200 KB
testcase_09 AC 77 ms
71,584 KB
testcase_10 AC 74 ms
71,504 KB
testcase_11 AC 83 ms
75,932 KB
testcase_12 AC 81 ms
76,156 KB
testcase_13 AC 86 ms
76,648 KB
testcase_14 AC 87 ms
76,752 KB
testcase_15 AC 103 ms
76,952 KB
testcase_16 AC 80 ms
76,080 KB
testcase_17 AC 74 ms
71,200 KB
testcase_18 AC 114 ms
76,840 KB
testcase_19 AC 93 ms
76,308 KB
testcase_20 AC 89 ms
76,144 KB
testcase_21 AC 75 ms
71,652 KB
testcase_22 AC 73 ms
71,576 KB
testcase_23 AC 75 ms
71,360 KB
testcase_24 AC 76 ms
71,304 KB
testcase_25 AC 82 ms
76,120 KB
testcase_26 AC 83 ms
76,052 KB
testcase_27 AC 80 ms
75,808 KB
testcase_28 AC 77 ms
71,460 KB
testcase_29 AC 94 ms
76,504 KB
testcase_30 AC 91 ms
76,656 KB
testcase_31 AC 80 ms
75,972 KB
testcase_32 AC 88 ms
76,944 KB
testcase_33 AC 99 ms
76,448 KB
testcase_34 AC 91 ms
76,676 KB
testcase_35 AC 86 ms
76,644 KB
testcase_36 AC 120 ms
77,992 KB
testcase_37 AC 80 ms
76,532 KB
testcase_38 AC 79 ms
76,400 KB
testcase_39 AC 81 ms
71,116 KB
testcase_40 AC 349 ms
77,968 KB
testcase_41 AC 82 ms
76,316 KB
testcase_42 AC 208 ms
77,820 KB
testcase_43 AC 75 ms
71,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

mod=998244353

N,K=map(int,input().split())
C=list(map(int,input().split()))
D=list(map(int,input().split()))

DP=[[0,0] for i in range(K+1)]
DP[0]=[0,1]

MAX=0
ANS=0


for i in range(K+1):
    if DP[i]!=[0,0]:
        for j in range(N):
            c,d=C[j],D[j]

            if i+c<=K:
                if DP[i+c][0]<DP[i][0]+d:
                    DP[i+c][0]=DP[i][0]+d
                    DP[i+c][1]=DP[i][1]
                elif DP[i+c][0]==DP[i][0]+d:
                    DP[i+c][1]+=DP[i][1]

for i in range(K+1):
    MAX=max(MAX,DP[i][0])

for i in range(K+1):
    if MAX==DP[i][0]:
        ANS+=DP[i][1]

print(MAX)
print(ANS%mod)
0