結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー brthyyjp
提出日時 2020-10-12 15:04:05
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 462 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 359,424 KB
最終ジャッジ日時 2024-07-20 18:00:29
合計ジャッジ時間 6,908 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13 MLE * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

n, q = map(int,input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

mod = 998244353

dp = [[0]*(n+1) for i in range(n)]
dp[0][0] = A[0]-1
dp[0][1] = 1
for i in range(1, n):
    for j in range(n+1):
        if j == 0:
            dp[i][j] = dp[i-1][j]*(A[i]-1)
            dp[i][j] %= mod
        else:
            dp[i][j] = dp[i-1][j-1]+dp[i-1][j]*(A[i]-1)
            dp[i][j] %= mod

for b in B:
    print(dp[n-1][b]%mod)
0