結果

問題 No.2429 Happiest Tabehodai Ways
ユーザー miho-4miho-4
提出日時 2023-08-18 23:20:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 378 ms / 2,000 ms
コード長 554 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 87,224 KB
実行使用メモリ 81,580 KB
最終ジャッジ日時 2023-09-03 03:05:01
合計ジャッジ時間 6,460 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 235 ms
78,240 KB
testcase_01 AC 80 ms
71,704 KB
testcase_02 AC 80 ms
71,688 KB
testcase_03 AC 80 ms
71,564 KB
testcase_04 AC 82 ms
71,848 KB
testcase_05 AC 80 ms
71,716 KB
testcase_06 AC 80 ms
71,560 KB
testcase_07 AC 80 ms
71,632 KB
testcase_08 AC 81 ms
71,580 KB
testcase_09 AC 83 ms
71,528 KB
testcase_10 AC 81 ms
71,628 KB
testcase_11 AC 91 ms
76,680 KB
testcase_12 AC 94 ms
77,920 KB
testcase_13 AC 99 ms
78,104 KB
testcase_14 AC 97 ms
78,100 KB
testcase_15 AC 120 ms
81,580 KB
testcase_16 AC 85 ms
76,976 KB
testcase_17 AC 79 ms
71,644 KB
testcase_18 AC 101 ms
77,988 KB
testcase_19 AC 102 ms
78,116 KB
testcase_20 AC 97 ms
77,884 KB
testcase_21 AC 84 ms
71,772 KB
testcase_22 AC 81 ms
71,524 KB
testcase_23 AC 79 ms
71,772 KB
testcase_24 AC 79 ms
71,516 KB
testcase_25 AC 91 ms
77,488 KB
testcase_26 AC 90 ms
77,672 KB
testcase_27 AC 85 ms
76,920 KB
testcase_28 AC 80 ms
71,788 KB
testcase_29 AC 106 ms
77,784 KB
testcase_30 AC 106 ms
78,168 KB
testcase_31 AC 91 ms
77,544 KB
testcase_32 AC 91 ms
78,020 KB
testcase_33 AC 111 ms
77,836 KB
testcase_34 AC 109 ms
78,704 KB
testcase_35 AC 104 ms
77,992 KB
testcase_36 AC 122 ms
78,180 KB
testcase_37 AC 90 ms
76,928 KB
testcase_38 AC 90 ms
77,616 KB
testcase_39 AC 84 ms
72,440 KB
testcase_40 AC 378 ms
78,208 KB
testcase_41 AC 95 ms
77,164 KB
testcase_42 AC 254 ms
78,432 KB
testcase_43 AC 81 ms
71,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
mod=998244353
n,k=map(int,input().split())
C=list(map(int,input().split()))
D=list(map(int,input().split()))
dic=defaultdict(int)
dic[(0,0)]=1
dp=[-1]*(k+1)
dp[0]=0
for i in range(k):
  if dp[i]==-1:continue
  for j in range(n):
    if i+C[j]<=k:
      if dp[i+C[j]]<=dp[i]+D[j]:
        dp[i+C[j]]=dp[i]+D[j]
        dic[(i+C[j],dp[i]+D[j])] += dic[ (i,dp[i]) ]
        dic[(i+C[j],dp[i]+D[j])]%=mod

maxC=max(dp)
ans=0
for i in range(k+1):
  if dp[i]==maxC:
    ans+=dic[(i,maxC)]
    ans%=mod
print(maxC)
print(ans)
0