結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー tcltktcltk
提出日時 2021-01-17 18:16:09
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 959 bytes
コンパイル時間 549 ms
コンパイル使用メモリ 82,280 KB
実行使用メモリ 367,636 KB
最終ジャッジ日時 2024-05-07 07:57:26
合計ジャッジ時間 10,842 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 143 ms
88,960 KB
testcase_01 AC 146 ms
88,704 KB
testcase_02 AC 144 ms
88,844 KB
testcase_03 AC 144 ms
89,104 KB
testcase_04 AC 145 ms
89,088 KB
testcase_05 AC 140 ms
89,088 KB
testcase_06 AC 141 ms
88,960 KB
testcase_07 AC 143 ms
88,704 KB
testcase_08 MLE -
testcase_09 AC 148 ms
89,240 KB
testcase_10 MLE -
testcase_11 MLE -
testcase_12 MLE -
testcase_13 MLE -
testcase_14 MLE -
testcase_15 MLE -
testcase_16 AC 233 ms
108,068 KB
testcase_17 AC 242 ms
108,020 KB
testcase_18 MLE -
testcase_19 MLE -
testcase_20 AC 160 ms
89,472 KB
testcase_21 MLE -
testcase_22 AC 152 ms
89,444 KB
testcase_23 AC 141 ms
88,888 KB
testcase_24 AC 143 ms
88,960 KB
testcase_25 MLE -
testcase_26 MLE -
権限があれば一括ダウンロードができます

ソースコード

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()))
    MaxA = max(A)

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

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


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