結果

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

ソースコード

diff #

import sys

input = sys.stdin.buffer.readline
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 _ in range(n + 1)]
dp[0][0] = 1
for i in range(n):
    ni = i + 1
    for j in range(n + 1):
        nj = j
        dp[ni][nj] += dp[i][j] * (A[i] - 1)
        dp[ni][nj] %= mod
        nj = j + 1
        if nj <= n:
            dp[ni][nj] += dp[i][j]
            dp[ni][nj] %= mod
for t in range(q):
    print(dp[n][B[t]] % mod)
0