結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー takakin
提出日時 2020-06-11 22:15:31
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 336 bytes
コンパイル時間 192 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 19,616 KB
最終ジャッジ日時 2024-06-24 03:24:33
合計ジャッジ時間 4,105 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 TLE * 1 -- * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n,q=map(int,input().split())
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
mod=998244353
DP=[1]+[0]*n
for i,a in enumerate(A):
  for j in range(i+1)[::-1]:
    DP[j+1]+=(a-1)*DP[j]
    if DP[j+1]>mod:
      DP[j+1]=DP[j+1]%mod
for b in B:
  print(DP[n-b])
0