結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー tcltktcltk
提出日時 2021-01-17 18:17:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 575 ms / 2,000 ms
コード長 944 bytes
コンパイル時間 991 ms
コンパイル使用メモリ 82,584 KB
実行使用メモリ 90,708 KB
最終ジャッジ日時 2024-05-07 07:59:05
合計ジャッジ時間 8,484 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
89,344 KB
testcase_01 AC 139 ms
88,960 KB
testcase_02 AC 143 ms
89,088 KB
testcase_03 AC 141 ms
89,088 KB
testcase_04 AC 142 ms
88,704 KB
testcase_05 AC 139 ms
89,092 KB
testcase_06 AC 141 ms
88,960 KB
testcase_07 AC 140 ms
89,216 KB
testcase_08 AC 307 ms
90,240 KB
testcase_09 AC 148 ms
89,472 KB
testcase_10 AC 557 ms
90,240 KB
testcase_11 AC 246 ms
89,856 KB
testcase_12 AC 226 ms
90,368 KB
testcase_13 AC 245 ms
90,240 KB
testcase_14 AC 250 ms
90,240 KB
testcase_15 AC 426 ms
90,496 KB
testcase_16 AC 196 ms
90,240 KB
testcase_17 AC 204 ms
90,112 KB
testcase_18 AC 404 ms
90,240 KB
testcase_19 AC 240 ms
90,084 KB
testcase_20 AC 147 ms
90,020 KB
testcase_21 AC 340 ms
90,096 KB
testcase_22 AC 145 ms
89,484 KB
testcase_23 AC 142 ms
89,184 KB
testcase_24 AC 140 ms
89,052 KB
testcase_25 AC 575 ms
90,556 KB
testcase_26 AC 343 ms
90,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#region Header
#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
from queue import PriorityQueue
import bisect
import heapq

def input():
    return sys.stdin.readline()[:-1]

sys.setrecursionlimit(1000000)
#endregion

# _INPUT = """4 3
# 1 3 3 3
# 3 1 4
# """
# sys.stdin = io.StringIO(_INPUT)

MOD = 998244353

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

    dp = [0 for _ in range(N+1)]
    dp[0] = 1
    for i in range(N):
        dp1 = [0 for _ in range(N+1)]
        for k in range(N+1):
            if dp[k] > 0:
                dp1[k] = (dp1[k] + dp[k] * (A[i] - 1)) % MOD
                dp1[k+1] = (dp1[k+1] + dp[k]) % MOD
        dp = dp1

    for b in B:
        print(dp[b])


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