結果
| 問題 |
No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-03-22 22:35:59 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 479 ms / 2,000 ms |
| コード長 | 399 bytes |
| コンパイル時間 | 469 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 77,696 KB |
| 最終ジャッジ日時 | 2024-10-10 17:01:54 |
| 合計ジャッジ時間 | 5,311 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
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[0] = 1
for a in A:
ndp = [0]*(n+1)
for i in range(n+1)[::-1]:
if dp[i] == 0:
continue
ndp[i+1] += dp[i]
ndp[i+1] %= mod
ndp[i] += dp[i]*(a-1)%mod
ndp[i] %= mod
dp = ndp
for b in B:
print(dp[b])