結果
問題 | No.2429 Happiest Tabehodai Ways |
ユーザー | norioc |
提出日時 | 2023-08-18 23:43:23 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 783 bytes |
コンパイル時間 | 1,033 ms |
コンパイル使用メモリ | 86,972 KB |
実行使用メモリ | 84,844 KB |
最終ジャッジ日時 | 2023-08-19 10:46:12 |
合計ジャッジ時間 | 6,096 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 108 ms
72,352 KB |
testcase_01 | AC | 109 ms
72,132 KB |
testcase_02 | AC | 111 ms
72,460 KB |
testcase_03 | AC | 109 ms
72,276 KB |
testcase_04 | AC | 107 ms
72,600 KB |
testcase_05 | AC | 108 ms
72,524 KB |
testcase_06 | AC | 108 ms
72,388 KB |
testcase_07 | AC | 107 ms
72,272 KB |
testcase_08 | AC | 113 ms
76,944 KB |
testcase_09 | AC | 109 ms
76,596 KB |
testcase_10 | AC | 170 ms
80,360 KB |
testcase_11 | AC | 139 ms
78,792 KB |
testcase_12 | AC | 230 ms
84,844 KB |
testcase_13 | AC | 143 ms
78,216 KB |
testcase_14 | TLE | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
ソースコード
from functools import cache MOD = 998244353 N, K = map(int, input().split()) C = list(map(int, input().split())) D = list(map(int, input().split())) def f(): dp = [0] * (K+1) for i in range(K): for j in range(N): c = C[j] d = D[j] if i+c > K: continue dp[i+c] = max(dp[i+c], dp[i] + d) m = 0 kk = 0 for k in range(K+1): if m < dp[k]: m = dp[k] kk = k return m, kk @cache def g(h, k): if k == 0: if h > 0: return 0 return 1 res = 0 for i in range(N): c = C[i] d = D[i] if h - d < 0 or k - c < 0: continue res += g(h-d, k-c) res %= MOD return res h, k = f() cnt = g(h, k) print(h) print(cnt)