結果

問題 No.1693 Invasion
ユーザー googol_S0googol_S0
提出日時 2021-10-01 21:26:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 199 ms / 2,000 ms
コード長 607 bytes
コンパイル時間 319 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 84,224 KB
最終ジャッジ日時 2023-09-26 16:24:01
合計ジャッジ時間 4,541 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
82,952 KB
testcase_01 AC 92 ms
82,972 KB
testcase_02 AC 92 ms
83,024 KB
testcase_03 AC 96 ms
83,016 KB
testcase_04 AC 92 ms
82,972 KB
testcase_05 AC 98 ms
83,036 KB
testcase_06 AC 97 ms
82,700 KB
testcase_07 AC 104 ms
83,280 KB
testcase_08 AC 98 ms
83,480 KB
testcase_09 AC 154 ms
83,872 KB
testcase_10 AC 115 ms
83,856 KB
testcase_11 AC 107 ms
83,856 KB
testcase_12 AC 127 ms
84,100 KB
testcase_13 AC 116 ms
83,712 KB
testcase_14 AC 118 ms
83,736 KB
testcase_15 AC 114 ms
83,668 KB
testcase_16 AC 140 ms
83,588 KB
testcase_17 AC 91 ms
82,744 KB
testcase_18 AC 176 ms
84,224 KB
testcase_19 AC 91 ms
83,720 KB
testcase_20 AC 97 ms
83,040 KB
testcase_21 AC 185 ms
84,184 KB
testcase_22 AC 199 ms
84,024 KB
testcase_23 AC 192 ms
84,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod=998244353
def cmb(n,r):
  if r<0 or r>n:
    return 0
  return ((g1[n]*g2[r]%mod)*g2[n-r])%mod

N=300000
g1=[1]*(N+3)
for i in range(2,N+3):
  g1[i]=g1[i-1]*i%mod
g2=[0]*len(g1)
g2[-1]=pow(g1[-1],mod-2,mod)
for i in range(N+1,-1,-1):
  g2[i]=g2[i+1]*(i+1)%mod
inv=[0]*(N+3)
for i in range(1,N+3):
  inv[i]=g2[i]*g1[i-1]%mod

N,M=map(int,input().split())
A=list(map(int,input().split()))
DP=[M+1]*(M+1)
DP[0]=0
ANS=0
for i in range(M+1):
  if DP[i]>M:
    continue
  ANS=(ANS+cmb(M-DP[i],i-DP[i]))%mod
  for j in range(N):
    if i+A[j]>M:
      continue
    DP[i+A[j]]=min(DP[i+A[j]],DP[i]+1)
print(ANS)
0