結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー NagisaNagisa
提出日時 2020-05-30 00:04:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 406 ms / 2,000 ms
コード長 392 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 81,152 KB
最終ジャッジ日時 2024-04-24 02:44:27
合計ジャッジ時間 4,776 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,096 KB
testcase_01 AC 41 ms
52,096 KB
testcase_02 AC 42 ms
51,968 KB
testcase_03 AC 46 ms
51,584 KB
testcase_04 AC 43 ms
51,712 KB
testcase_05 AC 41 ms
52,096 KB
testcase_06 AC 41 ms
51,840 KB
testcase_07 AC 41 ms
51,584 KB
testcase_08 AC 193 ms
76,928 KB
testcase_09 AC 48 ms
58,496 KB
testcase_10 AC 390 ms
79,744 KB
testcase_11 AC 141 ms
76,544 KB
testcase_12 AC 124 ms
76,544 KB
testcase_13 AC 143 ms
76,544 KB
testcase_14 AC 149 ms
76,800 KB
testcase_15 AC 284 ms
77,568 KB
testcase_16 AC 103 ms
76,416 KB
testcase_17 AC 109 ms
76,672 KB
testcase_18 AC 262 ms
77,696 KB
testcase_19 AC 137 ms
76,672 KB
testcase_20 AC 47 ms
58,368 KB
testcase_21 AC 198 ms
77,696 KB
testcase_22 AC 47 ms
58,496 KB
testcase_23 AC 41 ms
51,968 KB
testcase_24 AC 41 ms
51,968 KB
testcase_25 AC 406 ms
81,152 KB
testcase_26 AC 405 ms
78,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353
N, Q = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
dp = [0]*(N+1)
dp[0] = A[0]-1
dp[1] = 1
for k in range(1,N):
    temp = [0]*(N+1)
    temp[0] = dp[0]*(A[k]-1)
    temp[0] %= MOD
    for l in range(1,N+1):
        temp[l] = dp[l-1] + dp[l]*(A[k]-1)
        temp[l] %= MOD
    dp = temp[::]
for e in B:
    print(dp[e]%MOD)
0