結果

問題 No.1693 Invasion
ユーザー shotoyooshotoyoo
提出日時 2021-10-01 21:58:37
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,329 bytes
コンパイル時間 508 ms
コンパイル使用メモリ 86,900 KB
実行使用メモリ 274,876 KB
最終ジャッジ日時 2023-09-26 17:14:12
合計ジャッジ時間 8,983 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
78,592 KB
testcase_01 AC 78 ms
71,200 KB
testcase_02 AC 79 ms
71,212 KB
testcase_03 AC 81 ms
75,788 KB
testcase_04 AC 78 ms
71,208 KB
testcase_05 AC 85 ms
76,080 KB
testcase_06 AC 87 ms
76,064 KB
testcase_07 AC 81 ms
75,804 KB
testcase_08 AC 80 ms
75,832 KB
testcase_09 AC 554 ms
158,096 KB
testcase_10 AC 308 ms
116,612 KB
testcase_11 AC 174 ms
87,624 KB
testcase_12 AC 173 ms
80,156 KB
testcase_13 AC 131 ms
77,704 KB
testcase_14 AC 151 ms
78,300 KB
testcase_15 AC 126 ms
77,352 KB
testcase_16 AC 546 ms
171,676 KB
testcase_17 WA -
testcase_18 AC 290 ms
79,800 KB
testcase_19 AC 95 ms
79,132 KB
testcase_20 AC 83 ms
75,592 KB
testcase_21 AC 976 ms
270,500 KB
testcase_22 TLE -
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<<m) - 1
for i in range(n):
    v = a[i]
    for j in range(m-v+1):
        dp[j+v] |= dp[j]<<1
        dp[j+v] &= mask
ans = 0
for l in range(m+1):
    val = dp[l]
    if val==0:
        continue
    k = (val&(-val)).bit_length()-1
    ans += cmb(m-k, l-k)
    ans %= M
#     print(l,k)
print(ans%M)
0