結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-03-22 22:35:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 439 ms / 2,000 ms
コード長 399 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 77,952 KB
最終ジャッジ日時 2024-04-18 23:28:27
合計ジャッジ時間 5,056 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,840 KB
testcase_01 AC 39 ms
52,096 KB
testcase_02 AC 40 ms
51,712 KB
testcase_03 AC 39 ms
51,840 KB
testcase_04 AC 39 ms
51,712 KB
testcase_05 AC 39 ms
51,968 KB
testcase_06 AC 39 ms
51,968 KB
testcase_07 AC 38 ms
52,096 KB
testcase_08 AC 213 ms
76,672 KB
testcase_09 AC 47 ms
59,392 KB
testcase_10 AC 420 ms
77,952 KB
testcase_11 AC 154 ms
76,416 KB
testcase_12 AC 136 ms
76,416 KB
testcase_13 AC 149 ms
76,672 KB
testcase_14 AC 157 ms
76,288 KB
testcase_15 AC 304 ms
76,800 KB
testcase_16 AC 105 ms
76,288 KB
testcase_17 AC 111 ms
76,288 KB
testcase_18 AC 284 ms
77,056 KB
testcase_19 AC 149 ms
76,800 KB
testcase_20 AC 47 ms
59,264 KB
testcase_21 AC 232 ms
76,800 KB
testcase_22 AC 51 ms
59,776 KB
testcase_23 AC 40 ms
51,840 KB
testcase_24 AC 43 ms
51,584 KB
testcase_25 AC 439 ms
77,696 KB
testcase_26 AC 211 ms
77,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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[0] = 1
for a in A:
    ndp = [0]*(n+1)
    for i in range(n+1)[::-1]:
        if dp[i] == 0:
            continue
        ndp[i+1] += dp[i]
        ndp[i+1] %= mod
        ndp[i] += dp[i]*(a-1)%mod
        ndp[i] %= mod 
    dp = ndp
for b in B:
    print(dp[b])
0