結果

問題 No.1693 Invasion
ユーザー shotoyooshotoyoo
提出日時 2021-10-01 21:49:21
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,286 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 86,524 KB
実行使用メモリ 153,244 KB
最終ジャッジ日時 2023-09-26 16:59:34
合計ジャッジ時間 4,818 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
153,244 KB
testcase_01 AC 72 ms
71,116 KB
testcase_02 AC 81 ms
75,856 KB
testcase_03 AC 81 ms
75,948 KB
testcase_04 AC 74 ms
71,332 KB
testcase_05 AC 85 ms
76,644 KB
testcase_06 AC 81 ms
76,200 KB
testcase_07 AC 82 ms
76,356 KB
testcase_08 AC 79 ms
76,432 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


n,m = list(map(int, input().split()))
a = list(map(int, input().split()))
M = 998244353

### 素数の逆元とCombination

N = n+m+10 # 必要なテーブルサイズ
g1 = [0] * (N+1) # 元テーブル
g2 = [0] * (N+1) #逆元テーブル
inverse = [0] * (N+1) #逆元テーブル計算用テーブル
g1[0] = g1[1] = g2[0] = g2[1] = 1
inverse[0], inverse[1] = [0, 1] 
for i in range( 2, N + 1 ):
    g1[i] = ( g1[i-1] * i ) % M 
    inverse[i] = ( -inverse[M % i] * (M//i) ) % M # ai+b==0 mod M <=> i==-b*a^(-1) <=> i^(-1)==-b^(-1)*aより
    g2[i] = (g2[i-1] * inverse[i]) % M 
def cmb(n, r, M=M):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return ((g1[n] * g2[r] % M) * g2[n-r]) % M
def perm(n, r, M=M):
    if (r<0 or r>n):
        return 0
    return (g1[n] * g2[n-r]) % M

dp = [0]*(m+1)
dp[0] = 1
mask = (1<<n) - 1
for i in range(n):
    v = a[i]
    for j in range(m-v+1):
        dp[j+v] |= dp[j]<<1
ans = 0
for l in range(m+1):
    for k in range(m+1):
        if dp[l]>>k&1:
            ans += cmb(m-k, l-k)
            ans %= M
            break
print(ans%M)
0