結果

問題 No.2429 Happiest Tabehodai Ways
ユーザー ramdosramdos
提出日時 2023-08-18 14:16:21
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 641 bytes
コンパイル時間 902 ms
コンパイル使用メモリ 10,896 KB
実行使用メモリ 8,408 KB
最終ジャッジ日時 2023-08-19 10:44:26
合計ジャッジ時間 5,609 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
8,148 KB
testcase_01 AC 14 ms
8,160 KB
testcase_02 AC 15 ms
8,228 KB
testcase_03 AC 13 ms
8,088 KB
testcase_04 WA -
testcase_05 AC 14 ms
8,332 KB
testcase_06 WA -
testcase_07 AC 13 ms
8,092 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 53 ms
8,180 KB
testcase_13 WA -
testcase_14 AC 220 ms
8,360 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 77 ms
8,304 KB
testcase_20 WA -
testcase_21 AC 13 ms
8,368 KB
testcase_22 AC 14 ms
8,292 KB
testcase_23 AC 13 ms
8,260 KB
testcase_24 AC 13 ms
8,360 KB
testcase_25 AC 14 ms
8,332 KB
testcase_26 AC 13 ms
7,868 KB
testcase_27 AC 13 ms
8,328 KB
testcase_28 AC 125 ms
8,352 KB
testcase_29 AC 61 ms
8,380 KB
testcase_30 AC 16 ms
8,292 KB
testcase_31 AC 17 ms
8,292 KB
testcase_32 AC 175 ms
8,352 KB
testcase_33 AC 69 ms
8,384 KB
testcase_34 AC 21 ms
8,276 KB
testcase_35 AC 144 ms
8,332 KB
testcase_36 AC 415 ms
8,244 KB
testcase_37 AC 331 ms
8,164 KB
testcase_38 AC 229 ms
8,252 KB
testcase_39 AC 237 ms
8,252 KB
testcase_40 AC 221 ms
8,408 KB
testcase_41 AC 206 ms
8,244 KB
testcase_42 AC 15 ms
8,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,input().split())
C,D=list(map(int,input().split())),list(map(int,input().split()))
A=[0 for _ in range(1001)]
B=[1 for _ in range(1001)]
for i in range(N):
    if A[C[i]]<D[i]:
        A[C[i]]=D[i]
        B[C[i]]=1
    elif A[C[i]]==D[i]:
        B[C[i]]+=1
dp=[0 for _ in range(1001)]
pat=[0 for _ in range(1001)]
pat[0]=1
for i in range(1,K+1):
    for j in range(1,i+1):
        if dp[i] < dp[i-j]+A[j]:
            pat[i]=pat[i-j]*B[j]
            pat[i]%=998244353
            dp[i]= dp[i-j]+A[j]
        elif dp[i] == dp[i-j]+A[j]:
            pat[i]+=pat[i-j]*B[j]
            pat[i]%=998244353
print(dp[K])
print(pat[K])
0