結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー stngstng
提出日時 2022-08-19 17:54:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 450 ms / 2,000 ms
コード長 470 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 81,024 KB
最終ジャッジ日時 2024-04-16 21:32:13
合計ジャッジ時間 5,143 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
51,944 KB
testcase_01 AC 42 ms
51,940 KB
testcase_02 AC 43 ms
51,968 KB
testcase_03 AC 43 ms
51,712 KB
testcase_04 AC 41 ms
52,224 KB
testcase_05 AC 42 ms
52,224 KB
testcase_06 AC 42 ms
51,968 KB
testcase_07 AC 43 ms
52,608 KB
testcase_08 AC 209 ms
76,628 KB
testcase_09 AC 49 ms
58,636 KB
testcase_10 AC 437 ms
79,508 KB
testcase_11 AC 148 ms
76,412 KB
testcase_12 AC 127 ms
76,544 KB
testcase_13 AC 150 ms
76,800 KB
testcase_14 AC 154 ms
76,672 KB
testcase_15 AC 314 ms
78,584 KB
testcase_16 AC 104 ms
76,800 KB
testcase_17 AC 110 ms
76,556 KB
testcase_18 AC 290 ms
77,724 KB
testcase_19 AC 148 ms
76,672 KB
testcase_20 AC 48 ms
58,752 KB
testcase_21 AC 248 ms
77,136 KB
testcase_22 AC 50 ms
59,904 KB
testcase_23 AC 42 ms
52,096 KB
testcase_24 AC 41 ms
51,840 KB
testcase_25 AC 445 ms
79,048 KB
testcase_26 AC 450 ms
81,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
n,q = map(int,input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

#dp = [[0]*(n+1) for i in range(n+1)]
dp = [0]*(n+1)
dp[0] = 1

for i in range(n):
    ndp = [0]*(n+1)
    for j in range(n+1):
        if j >= 1:
            ndp[j] = dp[j]*(a[i]-1)%mod + dp[j-1]%mod
        else:
            ndp[j] = dp[j]*(a[i]-1)%mod
        ndp[j] %= mod
    dp = ndp[:]

for i in range(q):
    print(dp[b[i]])
#print(dp[n])
0