結果

問題 No.2429 Happiest Tabehodai Ways
ユーザー ramdosramdos
提出日時 2023-08-18 14:27:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 396 ms / 2,000 ms
コード長 675 bytes
コンパイル時間 232 ms
コンパイル使用メモリ 11,024 KB
実行使用メモリ 8,400 KB
最終ジャッジ日時 2023-09-03 03:02:35
合計ジャッジ時間 5,803 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 396 ms
8,044 KB
testcase_01 AC 16 ms
8,076 KB
testcase_02 AC 16 ms
7,944 KB
testcase_03 AC 18 ms
8,048 KB
testcase_04 AC 17 ms
7,996 KB
testcase_05 AC 16 ms
8,004 KB
testcase_06 AC 15 ms
8,128 KB
testcase_07 AC 17 ms
8,052 KB
testcase_08 AC 16 ms
8,048 KB
testcase_09 AC 17 ms
8,008 KB
testcase_10 AC 16 ms
8,212 KB
testcase_11 AC 17 ms
8,120 KB
testcase_12 AC 17 ms
8,028 KB
testcase_13 AC 57 ms
8,396 KB
testcase_14 AC 54 ms
8,320 KB
testcase_15 AC 213 ms
8,032 KB
testcase_16 AC 39 ms
8,232 KB
testcase_17 AC 18 ms
8,176 KB
testcase_18 AC 96 ms
8,300 KB
testcase_19 AC 145 ms
8,312 KB
testcase_20 AC 75 ms
8,292 KB
testcase_21 AC 15 ms
7,896 KB
testcase_22 AC 14 ms
8,112 KB
testcase_23 AC 14 ms
7,944 KB
testcase_24 AC 14 ms
7,940 KB
testcase_25 AC 15 ms
7,848 KB
testcase_26 AC 16 ms
8,064 KB
testcase_27 AC 14 ms
7,940 KB
testcase_28 AC 14 ms
8,024 KB
testcase_29 AC 122 ms
8,348 KB
testcase_30 AC 61 ms
8,160 KB
testcase_31 AC 19 ms
8,280 KB
testcase_32 AC 18 ms
8,012 KB
testcase_33 AC 192 ms
8,400 KB
testcase_34 AC 72 ms
8,308 KB
testcase_35 AC 23 ms
8,100 KB
testcase_36 AC 180 ms
7,940 KB
testcase_37 AC 385 ms
8,168 KB
testcase_38 AC 318 ms
8,080 KB
testcase_39 AC 243 ms
7,968 KB
testcase_40 AC 259 ms
8,164 KB
testcase_41 AC 227 ms
8,032 KB
testcase_42 AC 216 ms
8,164 KB
testcase_43 AC 15 ms
8,096 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=[0 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
    if dp[i]==0:
        pat[i]=1
print(dp[K])
print(pat[K])
0