結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー tamatotamato
提出日時 2020-05-29 21:42:28
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 622 bytes
コンパイル時間 393 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 359,064 KB
最終ジャッジ日時 2024-04-23 20:53:42
合計ジャッジ時間 7,227 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,224 KB
testcase_01 AC 38 ms
52,224 KB
testcase_02 AC 38 ms
52,224 KB
testcase_03 AC 37 ms
52,352 KB
testcase_04 AC 37 ms
52,096 KB
testcase_05 AC 38 ms
52,352 KB
testcase_06 AC 41 ms
52,096 KB
testcase_07 AC 38 ms
52,608 KB
testcase_08 MLE -
testcase_09 AC 42 ms
59,392 KB
testcase_10 MLE -
testcase_11 MLE -
testcase_12 AC 168 ms
113,888 KB
testcase_13 MLE -
testcase_14 MLE -
testcase_15 MLE -
testcase_16 AC 118 ms
91,392 KB
testcase_17 AC 127 ms
91,392 KB
testcase_18 MLE -
testcase_19 MLE -
testcase_20 AC 43 ms
59,264 KB
testcase_21 MLE -
testcase_22 AC 44 ms
60,336 KB
testcase_23 AC 37 ms
52,224 KB
testcase_24 AC 40 ms
52,096 KB
testcase_25 MLE -
testcase_26 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N, Q = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    dp = [[0] * (N+1) for _ in range(N+1)]
    dp[0][0] = 1
    for i in range(N):
        a = A[i]
        for j in range(N+1):
            if dp[i][j] == 0:
                continue
            dp[i+1][j] = (dp[i+1][j] + dp[i][j] * (a - 1))%mod
            if j+1 <= N:
                dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j])%mod
    for b in B:
        print(dp[-1][b])


if __name__ == '__main__':
    main()
0