結果
| 問題 | No.1066 #いろいろな色 / Red and Blue and more various colors (Easy) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-24 17:49:30 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 141 ms / 2,000 ms |
| コード長 | 369 bytes |
| 記録 | |
| コンパイル時間 | 125 ms |
| コンパイル使用メモリ | 85,632 KB |
| 実行使用メモリ | 81,664 KB |
| 最終ジャッジ日時 | 2026-03-24 04:34:33 |
| 合計ジャッジ時間 | 2,680 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 |
ソースコード
MOD = 998244353 n, q = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) dp = [(a[0] - 1) % MOD, 1, 0] for i in range(1, n): ndp = [0 for _ in range(i + 3)] ndp[0] = (dp[0] * (a[i] - 1)) % MOD for j in range(1, i + 2): ndp[j] = (dp[j] * (a[i] - 1) + dp[j - 1]) % MOD dp = ndp for i in range(q): print(dp[b[i]])