結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー nephrologistnephrologist
提出日時 2020-05-29 21:56:27
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 507 bytes
コンパイル時間 182 ms
コンパイル使用メモリ 82,548 KB
実行使用メモリ 359,712 KB
最終ジャッジ日時 2024-04-23 21:57:21
合計ジャッジ時間 8,733 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,072 KB
testcase_01 AC 39 ms
52,248 KB
testcase_02 AC 39 ms
53,096 KB
testcase_03 AC 38 ms
53,760 KB
testcase_04 AC 39 ms
53,392 KB
testcase_05 AC 38 ms
52,436 KB
testcase_06 AC 40 ms
53,720 KB
testcase_07 AC 39 ms
52,420 KB
testcase_08 MLE -
testcase_09 AC 47 ms
61,500 KB
testcase_10 MLE -
testcase_11 MLE -
testcase_12 AC 218 ms
114,528 KB
testcase_13 MLE -
testcase_14 MLE -
testcase_15 MLE -
testcase_16 AC 150 ms
91,948 KB
testcase_17 AC 161 ms
92,372 KB
testcase_18 MLE -
testcase_19 MLE -
testcase_20 AC 45 ms
61,336 KB
testcase_21 MLE -
testcase_22 AC 47 ms
61,528 KB
testcase_23 AC 38 ms
52,944 KB
testcase_24 AC 39 ms
52,764 KB
testcase_25 MLE -
testcase_26 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

input = sys.stdin.buffer.readline
n, q = map(int, input().split())
A = list(map(int, input().split()))

mod = 998244353
dp = [[0] * (n + 1) for _ in range(n + 1)]
dp[0][0] = 1
for i in range(n):
    ni = i + 1
    for j in range(n + 1):
        nj = j
        dp[ni][nj] += dp[i][j] * (A[i] - 1)
        dp[ni][nj] %= mod
        nj = j + 1
        if nj <= n:
            dp[ni][nj] += dp[i][j]
            dp[ni][nj] %= mod

B = map(int, input().split())
for t in B:
    print(dp[n][t] % mod)
0