結果
問題 |
No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
|
ユーザー |
![]() |
提出日時 | 2025-03-20 18:53:18 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 777 bytes |
コンパイル時間 | 171 ms |
コンパイル使用メモリ | 82,456 KB |
実行使用メモリ | 77,164 KB |
最終ジャッジ日時 | 2025-03-20 18:54:29 |
合計ジャッジ時間 | 3,547 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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)))