結果
問題 | No.1066 #いろいろな色 / Red and Blue and more various colors (Easy) |
ユーザー |
![]() |
提出日時 | 2020-05-29 22:06:48 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 332 ms / 2,000 ms |
コード長 | 412 bytes |
コンパイル時間 | 374 ms |
コンパイル使用メモリ | 82,596 KB |
実行使用メモリ | 70,220 KB |
最終ジャッジ日時 | 2024-11-06 04:56:03 |
合計ジャッジ時間 | 4,148 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
ソースコード
import sys input = sys.stdin.readline 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[1] = 1 dp[0] = a[0] - 1 #print(dp) for i in range(1, N): for j in range(N, -1, -1): if dp[j] == 0: continue dp[j + 1] += dp[j] dp[j + 1] %= mod dp[j] += dp[j] * (a[i] - 2) dp[j] %= mod for x in b: print(dp[x])