結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー H3PO4H3PO4
提出日時 2020-05-29 22:07:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 980 ms / 2,000 ms
コード長 360 bytes
コンパイル時間 70 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 44,580 KB
最終ジャッジ日時 2024-04-23 22:42:01
合計ジャッジ時間 17,585 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 450 ms
44,068 KB
testcase_01 AC 453 ms
44,328 KB
testcase_02 AC 451 ms
43,940 KB
testcase_03 AC 457 ms
44,060 KB
testcase_04 AC 464 ms
44,444 KB
testcase_05 AC 459 ms
44,312 KB
testcase_06 AC 453 ms
44,324 KB
testcase_07 AC 453 ms
44,196 KB
testcase_08 AC 656 ms
44,580 KB
testcase_09 AC 450 ms
43,980 KB
testcase_10 AC 958 ms
43,944 KB
testcase_11 AC 576 ms
44,200 KB
testcase_12 AC 561 ms
44,332 KB
testcase_13 AC 584 ms
44,320 KB
testcase_14 AC 587 ms
44,192 KB
testcase_15 AC 802 ms
44,316 KB
testcase_16 AC 513 ms
44,072 KB
testcase_17 AC 524 ms
43,936 KB
testcase_18 AC 774 ms
44,072 KB
testcase_19 AC 569 ms
44,448 KB
testcase_20 AC 460 ms
44,196 KB
testcase_21 AC 702 ms
44,320 KB
testcase_22 AC 450 ms
44,320 KB
testcase_23 AC 454 ms
44,072 KB
testcase_24 AC 448 ms
44,076 KB
testcase_25 AC 971 ms
44,320 KB
testcase_26 AC 980 ms
44,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

N, Q = map(int, input().split())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))
MOD = 998244353

dp = np.zeros(N + 2, dtype=np.int64)
dp[1] = 1
for i, a in enumerate(A):
    new_dp = np.zeros_like(dp)
    new_dp[1:] = dp[1:] * (a - 1) + dp[:-1]
    new_dp %= MOD
    dp = new_dp

for b in B:
    print(dp[b + 1])
0