結果

問題 No.2429 Happiest Tabehodai Ways
ユーザー KoiKoi
提出日時 2023-08-11 19:56:52
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 853 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 82,496 KB
実行使用メモリ 65,072 KB
最終ジャッジ日時 2024-05-06 17:56:27
合計ジャッジ時間 3,990 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 37 ms
52,952 KB
testcase_02 AC 37 ms
53,020 KB
testcase_03 AC 43 ms
58,528 KB
testcase_04 AC 39 ms
53,016 KB
testcase_05 AC 38 ms
53,312 KB
testcase_06 AC 38 ms
53,240 KB
testcase_07 AC 37 ms
53,076 KB
testcase_08 AC 37 ms
53,420 KB
testcase_09 AC 46 ms
60,652 KB
testcase_10 AC 39 ms
52,964 KB
testcase_11 AC 44 ms
60,964 KB
testcase_12 AC 46 ms
60,804 KB
testcase_13 AC 51 ms
63,580 KB
testcase_14 AC 51 ms
63,168 KB
testcase_15 AC 56 ms
64,016 KB
testcase_16 AC 49 ms
62,016 KB
testcase_17 AC 42 ms
59,328 KB
testcase_18 AC 54 ms
63,496 KB
testcase_19 AC 54 ms
64,860 KB
testcase_20 AC 52 ms
63,652 KB
testcase_21 AC 38 ms
52,396 KB
testcase_22 AC 38 ms
51,944 KB
testcase_23 AC 38 ms
53,200 KB
testcase_24 AC 38 ms
52,584 KB
testcase_25 AC 43 ms
59,372 KB
testcase_26 AC 45 ms
62,064 KB
testcase_27 AC 39 ms
53,000 KB
testcase_28 AC 38 ms
53,340 KB
testcase_29 WA -
testcase_30 AC 53 ms
63,036 KB
testcase_31 WA -
testcase_32 AC 48 ms
62,412 KB
testcase_33 AC 55 ms
63,524 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 51 ms
62,192 KB
testcase_38 AC 50 ms
61,240 KB
testcase_39 AC 50 ms
60,708 KB
testcase_40 AC 53 ms
63,312 KB
testcase_41 WA -
testcase_42 AC 56 ms
65,072 KB
testcase_43 AC 39 ms
53,808 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

Mod=998244353
N,K=map(int,input().split())
C=list(map(int,input().split()))
D=list(map(int,input().split()))
dp_hap=[0]*(K+1)
dp_way=[1]*(K+1)
L=[[-1,0] for _ in range(K+1)]
#dp_hap[i]:=カロリーの和がi以下で得られる満足度の最大値
#dp_way[i]:=カロリーの和がi以下で得られる満足度が最大となる組み合わせの個数
for i in range(N):
    if(C[i]>K):
        continue
    if(D[i]>L[C[i]][0]):
        L[C[i]][0]=D[i]
        L[C[i]][1]=1
    elif(D[i]==L[C[i]][0]):
        L[C[i]][1]+=1
# print(L)
for i in range(1,K+1):
    for j in range(1,i+1):
        if(dp_hap[i]<L[j][0]+dp_hap[i-j]):
            dp_hap[i]=L[j][0]+dp_hap[i-j]
            dp_way[i]=(L[j][1]*dp_way[i-j])%Mod
        elif(dp_hap[i]==L[j][0]+dp_hap[i-j]):
            dp_way[i]+=(L[j][1]*dp_way[i-j])%Mod
print(dp_hap[K])
print(dp_way[K])
0