結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー rlangevinrlangevin
提出日時 2023-01-30 12:43:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 445 ms / 2,000 ms
コード長 383 bytes
コンパイル時間 401 ms
コンパイル使用メモリ 86,988 KB
実行使用メモリ 79,992 KB
最終ジャッジ日時 2023-09-12 13:37:03
合計ジャッジ時間 6,304 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,508 KB
testcase_01 AC 74 ms
71,280 KB
testcase_02 AC 75 ms
71,168 KB
testcase_03 AC 74 ms
71,480 KB
testcase_04 AC 74 ms
71,200 KB
testcase_05 AC 75 ms
71,248 KB
testcase_06 AC 74 ms
71,400 KB
testcase_07 AC 72 ms
71,324 KB
testcase_08 AC 220 ms
77,780 KB
testcase_09 AC 78 ms
76,256 KB
testcase_10 AC 432 ms
79,200 KB
testcase_11 AC 165 ms
77,692 KB
testcase_12 AC 147 ms
77,636 KB
testcase_13 AC 164 ms
77,592 KB
testcase_14 AC 170 ms
77,776 KB
testcase_15 AC 316 ms
78,564 KB
testcase_16 AC 124 ms
77,524 KB
testcase_17 AC 130 ms
77,764 KB
testcase_18 AC 298 ms
78,204 KB
testcase_19 AC 163 ms
77,888 KB
testcase_20 AC 76 ms
75,876 KB
testcase_21 AC 251 ms
78,216 KB
testcase_22 AC 80 ms
75,880 KB
testcase_23 AC 76 ms
71,320 KB
testcase_24 AC 76 ms
71,000 KB
testcase_25 AC 445 ms
79,664 KB
testcase_26 AC 444 ms
79,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, Q = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
mod = 998244353

pre = [0] * (N + 5)
pre[0] = 1
for i in range(N):
    dp = [0] * (N + 5)
    for j in range(N):
        dp[j + 1] += pre[j]
        dp[j] += pre[j] * (A[i] - 1)
        dp[j] %= mod
        dp[j + 1] %= mod
    dp, pre = pre, dp

for b in B:
    print(pre[b])

0