結果
| 問題 |
No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-24 17:49:30 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 224 ms / 2,000 ms |
| コード長 | 369 bytes |
| コンパイル時間 | 129 ms |
| コンパイル使用メモリ | 82,376 KB |
| 実行使用メモリ | 76,716 KB |
| 最終ジャッジ日時 | 2024-07-02 20:54:10 |
| 合計ジャッジ時間 | 3,274 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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]])