結果

問題 No.1693 Invasion
ユーザー SidewaysOwlSidewaysOwl
提出日時 2021-10-01 22:09:06
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,026 bytes
コンパイル時間 354 ms
コンパイル使用メモリ 86,688 KB
実行使用メモリ 154,548 KB
最終ジャッジ日時 2023-09-26 17:30:59
合計ジャッジ時間 11,610 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
154,548 KB
testcase_01 AC 71 ms
71,064 KB
testcase_02 AC 85 ms
76,024 KB
testcase_03 AC 81 ms
75,888 KB
testcase_04 AC 73 ms
71,208 KB
testcase_05 AC 82 ms
76,400 KB
testcase_06 AC 86 ms
76,192 KB
testcase_07 AC 89 ms
76,328 KB
testcase_08 AC 84 ms
76,336 KB
testcase_09 TLE -
testcase_10 AC 1,394 ms
101,172 KB
testcase_11 AC 849 ms
86,028 KB
testcase_12 AC 1,058 ms
90,480 KB
testcase_13 AC 461 ms
81,188 KB
testcase_14 AC 304 ms
80,168 KB
testcase_15 AC 289 ms
78,648 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
a = list(map(int,input().split()))
inf = 10 ** 5 + 1
dp = [inf] * (m+1)
dp[0] = 0
while True:
    n_dp = [inf] * (m+1)
    flg = False
    for i in range(m+1):
        n_dp[i] = min(dp[i],n_dp[i])
        for j in range(n):
            if dp[i] != inf:
                if a[j] + i <= m:
                    if i <= m - j:
                        if n_dp[i + a[j]] > dp[i] + 1:
#                             print(i,j)
                            n_dp[i + a[j]] = dp[i] + 1
                            flg = True
    if dp == n_dp:
        break
    dp = n_dp
ans = 0
n = m
fac_arr = [1] * (n+1)
r_s_fac_arr = [1] * (n+1)
mod = 998244353
for i in range(1,n+1):
    fac_arr[i] = (fac_arr[i-1] % mod) * i % mod
    r_s_fac_arr[i] = (r_s_fac_arr[i-1] % mod) * pow(i,mod-2,mod) % mod 
def nCk_Mod(n,k):
    return fac_arr[n]  % mod *  r_s_fac_arr[k] % mod * r_s_fac_arr[n-k] % mod
ans = 0
for i in range(m+1):
    if dp[i] != inf:
        ans += nCk_Mod(m-dp[i],i-dp[i])
        ans %= mod
print(ans)
0