結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,968 KB
testcase_01 AC 44 ms
52,352 KB
testcase_02 AC 38 ms
51,968 KB
testcase_03 AC 39 ms
52,224 KB
testcase_04 AC 40 ms
51,968 KB
testcase_05 AC 39 ms
52,096 KB
testcase_06 AC 39 ms
51,840 KB
testcase_07 AC 39 ms
52,608 KB
testcase_08 MLE -
testcase_09 AC 46 ms
59,520 KB
testcase_10 MLE -
testcase_11 MLE -
testcase_12 AC 218 ms
114,108 KB
testcase_13 MLE -
testcase_14 MLE -
testcase_15 MLE -
testcase_16 AC 152 ms
91,392 KB
testcase_17 AC 163 ms
91,648 KB
testcase_18 MLE -
testcase_19 MLE -
testcase_20 AC 46 ms
59,648 KB
testcase_21 MLE -
testcase_22 AC 49 ms
60,800 KB
testcase_23 AC 39 ms
52,608 KB
testcase_24 AC 39 ms
52,096 KB
testcase_25 MLE -
testcase_26 MLE -
権限があれば一括ダウンロードができます

ソースコード

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) 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
for t in range(q):
    print(dp[n][B[t]] % mod)
0