結果

問題 No.2429 Happiest Tabehodai Ways
ユーザー Navier_BoltzmannNavier_Boltzmann
提出日時 2023-08-24 20:38:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 932 bytes
コンパイル時間 298 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 94,008 KB
最終ジャッジ日時 2023-09-03 03:06:42
合計ジャッジ時間 6,435 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
85,140 KB
testcase_01 AC 95 ms
73,064 KB
testcase_02 AC 96 ms
73,036 KB
testcase_03 AC 95 ms
72,852 KB
testcase_04 AC 92 ms
72,956 KB
testcase_05 AC 90 ms
73,136 KB
testcase_06 AC 93 ms
73,148 KB
testcase_07 AC 92 ms
72,808 KB
testcase_08 AC 91 ms
72,692 KB
testcase_09 AC 96 ms
77,468 KB
testcase_10 AC 96 ms
77,484 KB
testcase_11 AC 103 ms
77,676 KB
testcase_12 AC 105 ms
77,640 KB
testcase_13 AC 113 ms
78,488 KB
testcase_14 AC 115 ms
78,324 KB
testcase_15 AC 128 ms
78,576 KB
testcase_16 AC 102 ms
77,684 KB
testcase_17 AC 97 ms
77,792 KB
testcase_18 AC 110 ms
78,132 KB
testcase_19 AC 112 ms
78,212 KB
testcase_20 AC 109 ms
78,152 KB
testcase_21 AC 91 ms
73,136 KB
testcase_22 AC 95 ms
73,248 KB
testcase_23 AC 87 ms
72,920 KB
testcase_24 AC 89 ms
72,952 KB
testcase_25 AC 102 ms
77,640 KB
testcase_26 AC 102 ms
77,708 KB
testcase_27 AC 95 ms
77,668 KB
testcase_28 AC 94 ms
72,812 KB
testcase_29 AC 120 ms
78,396 KB
testcase_30 AC 118 ms
78,628 KB
testcase_31 AC 110 ms
78,216 KB
testcase_32 AC 111 ms
78,536 KB
testcase_33 AC 120 ms
78,428 KB
testcase_34 AC 116 ms
78,700 KB
testcase_35 AC 110 ms
78,416 KB
testcase_36 AC 124 ms
78,608 KB
testcase_37 AC 110 ms
78,352 KB
testcase_38 AC 110 ms
78,380 KB
testcase_39 AC 93 ms
72,908 KB
testcase_40 AC 147 ms
94,008 KB
testcase_41 AC 109 ms
77,888 KB
testcase_42 AC 132 ms
81,832 KB
testcase_43 AC 90 ms
72,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
input = sys.stdin.readline

N,K = map(int,input().split())
C = list(map(int,input().split()))
D = list(map(int,input().split()))

mod = 998244353

dp = [-1]*(K+2)
dp[0] = 0
for i in range(N):
    
    c,d = C[i],D[i]
    
    for j in range(K):
        
        if dp[j]!=-1:
            dp[min(K+1,j+c)] = max(dp[min(K+1,j+c)],dp[j]+d)

e = [[] for _ in range(K+2)]

for i in range(N):
    
    c,d = C[i],D[i]
    
    for j in range(K):
        
        k = min(K+1,j+c)
        if dp[k]-dp[j]==d:
            e[j].append(k)
            

val = [0]*(K+2)

# print(dp)

val[0] = 1
for i in range(K):
    
    
    for j in e[i]:
        
        
        val[j] += val[i]
        val[j] %= mod


M = max(dp[:K+1])
ans = 0
for j in range(K+1):
    if dp[j]==M:
        ans += val[j]
        ans %= mod
print(M)
print(ans)
0