結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー wolgnikwolgnik
提出日時 2020-05-29 22:06:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 303 ms / 2,000 ms
コード長 412 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 82,268 KB
実行使用メモリ 70,320 KB
最終ジャッジ日時 2024-04-23 22:39:36
合計ジャッジ時間 3,665 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,684 KB
testcase_01 AC 33 ms
53,032 KB
testcase_02 AC 34 ms
53,608 KB
testcase_03 AC 34 ms
52,628 KB
testcase_04 AC 33 ms
52,480 KB
testcase_05 AC 34 ms
52,680 KB
testcase_06 AC 34 ms
52,388 KB
testcase_07 AC 32 ms
52,768 KB
testcase_08 AC 142 ms
68,652 KB
testcase_09 AC 42 ms
61,012 KB
testcase_10 AC 294 ms
70,320 KB
testcase_11 AC 103 ms
66,724 KB
testcase_12 AC 91 ms
67,956 KB
testcase_13 AC 105 ms
68,140 KB
testcase_14 AC 109 ms
67,332 KB
testcase_15 AC 212 ms
69,148 KB
testcase_16 AC 74 ms
66,732 KB
testcase_17 AC 76 ms
66,680 KB
testcase_18 AC 196 ms
68,792 KB
testcase_19 AC 101 ms
66,840 KB
testcase_20 AC 41 ms
60,508 KB
testcase_21 AC 165 ms
67,788 KB
testcase_22 AC 44 ms
60,196 KB
testcase_23 AC 34 ms
52,432 KB
testcase_24 AC 35 ms
53,076 KB
testcase_25 AC 303 ms
69,444 KB
testcase_26 AC 146 ms
68,068 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.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)
dp[1] = 1
dp[0] = a[0] - 1
#print(dp)
for i in range(1, N):
  for j in range(N, -1, -1):
    if dp[j] == 0: continue
    dp[j + 1] += dp[j]
    dp[j + 1] %= mod
    dp[j] += dp[j] * (a[i] - 2)
    dp[j] %= mod
for x in b: print(dp[x])
0