結果
| 問題 | No.1066 #いろいろな色 / Red and Blue and more various colors (Easy) |
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 21:15:29 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 777 bytes |
| 記録 | |
| コンパイル時間 | 269 ms |
| コンパイル使用メモリ | 82,820 KB |
| 実行使用メモリ | 77,032 KB |
| 最終ジャッジ日時 | 2025-03-20 21:15:58 |
| 合計ジャッジ時間 | 3,615 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 24 |
ソースコード
mod = 998244353
n, q = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
dp = [0] * (n + 1)
dp[0] = 1
current_max_j = 0 # Tracks the maximum j with non-zero value
for a in A:
new_dp = [0] * (n + 1)
ai_minus_1 = (a - 1) % mod
for j in range(current_max_j + 1):
val = dp[j]
if val == 0:
continue
# Not choosing color 1 from this box
new_dp[j] = (new_dp[j] + val * ai_minus_1) % mod
# Choosing color 1 from this box
if j + 1 <= n:
new_dp[j + 1] = (new_dp[j + 1] + val) % mod
dp = new_dp
current_max_j = min(current_max_j + 1, n)
# Prepare the results for each query
results = [dp[b] % mod for b in B]
print(' '.join(map(str, results)))
lam6er