結果

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

ソースコード

diff #

N,Q = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
mod = 998244353

L = [[0]*(N+1) for _ in range(2)]
L[0][0] = 1
for i in range(N):
    a = i%2
    b = (i+1)%2
    L[b] = [0]*(N+1)
    for j in range(i+2):
        L[b][j] += L[a][j]*(A[i]-1)
        if j > 0:
            L[b][j] += L[a][j-1]
        L[b][j] %= mod

for b in B:
    print(L[N%2][b])
0