結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー qibqib
提出日時 2022-10-24 17:45:01
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 417 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 360,016 KB
最終ジャッジ日時 2023-09-15 18:50:11
合計ジャッジ時間 7,068 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,248 KB
testcase_01 AC 72 ms
71,444 KB
testcase_02 AC 71 ms
71,488 KB
testcase_03 AC 71 ms
71,252 KB
testcase_04 AC 72 ms
71,372 KB
testcase_05 AC 71 ms
71,156 KB
testcase_06 AC 71 ms
71,308 KB
testcase_07 AC 70 ms
71,364 KB
testcase_08 MLE -
testcase_09 AC 76 ms
76,092 KB
testcase_10 MLE -
testcase_11 MLE -
testcase_12 AC 165 ms
110,448 KB
testcase_13 MLE -
testcase_14 MLE -
testcase_15 MLE -
testcase_16 AC 127 ms
89,292 KB
testcase_17 AC 147 ms
106,704 KB
testcase_18 MLE -
testcase_19 MLE -
testcase_20 AC 75 ms
76,120 KB
testcase_21 MLE -
testcase_22 AC 76 ms
75,980 KB
testcase_23 AC 68 ms
71,536 KB
testcase_24 AC 68 ms
71,264 KB
testcase_25 MLE -
testcase_26 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353

n, q = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

dp = [[0 for _ in range(n + 1)] for _ in range(n)]
dp[0][0] = (a[0] - 1) % MOD
dp[0][1] = 1
for i in range(1, n):
	dp[i][0] = (dp[i - 1][0] * (a[i] - 1)) % MOD
	for j in range(1, i + 2):
		dp[i][j] = (dp[i - 1][j] * (a[i] - 1) + dp[i - 1][j - 1]) % MOD

for i in range(q):
  print(dp[-1][b[i]])
0