結果

問題 No.2429 Happiest Tabehodai Ways
ユーザー KoiKoi
提出日時 2023-08-11 21:19:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 890 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 77,112 KB
最終ジャッジ日時 2023-09-03 03:02:13
合計ジャッジ時間 5,457 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
76,788 KB
testcase_01 AC 70 ms
71,472 KB
testcase_02 AC 72 ms
71,320 KB
testcase_03 AC 76 ms
75,948 KB
testcase_04 AC 72 ms
71,316 KB
testcase_05 AC 69 ms
71,444 KB
testcase_06 AC 70 ms
71,516 KB
testcase_07 AC 70 ms
71,524 KB
testcase_08 AC 71 ms
71,436 KB
testcase_09 AC 77 ms
76,480 KB
testcase_10 AC 69 ms
71,448 KB
testcase_11 AC 76 ms
75,812 KB
testcase_12 AC 78 ms
76,492 KB
testcase_13 AC 84 ms
77,112 KB
testcase_14 AC 87 ms
76,848 KB
testcase_15 AC 92 ms
77,028 KB
testcase_16 AC 84 ms
76,780 KB
testcase_17 AC 76 ms
76,144 KB
testcase_18 AC 87 ms
76,924 KB
testcase_19 AC 88 ms
76,736 KB
testcase_20 AC 85 ms
76,812 KB
testcase_21 AC 71 ms
71,600 KB
testcase_22 AC 71 ms
71,600 KB
testcase_23 AC 71 ms
71,316 KB
testcase_24 AC 72 ms
71,324 KB
testcase_25 AC 76 ms
76,128 KB
testcase_26 AC 79 ms
76,352 KB
testcase_27 AC 72 ms
71,444 KB
testcase_28 AC 71 ms
71,480 KB
testcase_29 AC 83 ms
76,868 KB
testcase_30 AC 84 ms
76,940 KB
testcase_31 AC 78 ms
76,288 KB
testcase_32 AC 82 ms
76,872 KB
testcase_33 AC 86 ms
76,808 KB
testcase_34 AC 88 ms
76,876 KB
testcase_35 AC 82 ms
76,800 KB
testcase_36 AC 91 ms
76,748 KB
testcase_37 AC 84 ms
76,792 KB
testcase_38 AC 84 ms
76,816 KB
testcase_39 AC 83 ms
76,776 KB
testcase_40 AC 86 ms
76,868 KB
testcase_41 AC 85 ms
76,652 KB
testcase_42 AC 88 ms
77,008 KB
testcase_43 AC 72 ms
71,444 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
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
            dp_way[i]%=Mod
        elif(dp_hap[i]==L[j][0]+dp_hap[i-j]):
            dp_way[i]+=(L[j][1]*dp_way[i-j])%Mod
            dp_way[i]%=Mod
print(dp_hap[K])
print(dp_way[K])
0