結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー mkawa2mkawa2
提出日時 2021-05-27 22:49:27
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 231 ms / 2,000 ms
コード長 1,014 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 82,816 KB
実行使用メモリ 77,952 KB
最終ジャッジ日時 2024-04-24 09:11:12
合計ジャッジ時間 3,555 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
51,968 KB
testcase_01 AC 37 ms
52,352 KB
testcase_02 AC 39 ms
52,224 KB
testcase_03 AC 35 ms
51,840 KB
testcase_04 AC 35 ms
52,352 KB
testcase_05 AC 35 ms
52,096 KB
testcase_06 AC 35 ms
52,224 KB
testcase_07 AC 35 ms
52,224 KB
testcase_08 AC 126 ms
76,544 KB
testcase_09 AC 41 ms
58,752 KB
testcase_10 AC 231 ms
77,952 KB
testcase_11 AC 108 ms
76,160 KB
testcase_12 AC 87 ms
76,160 KB
testcase_13 AC 98 ms
76,416 KB
testcase_14 AC 100 ms
76,800 KB
testcase_15 AC 179 ms
76,672 KB
testcase_16 AC 79 ms
76,416 KB
testcase_17 AC 81 ms
76,416 KB
testcase_18 AC 166 ms
76,416 KB
testcase_19 AC 97 ms
76,160 KB
testcase_20 AC 40 ms
58,624 KB
testcase_21 AC 140 ms
76,800 KB
testcase_22 AC 45 ms
58,880 KB
testcase_23 AC 34 ms
52,096 KB
testcase_24 AC 38 ms
52,352 KB
testcase_25 AC 228 ms
77,184 KB
testcase_26 AC 128 ms
77,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
dij = [(0, 1), (1, 0), (1, 1), (1, -1)]
inf = 10**16
md = 998244353
# md = 10**9+7

n, q = LI()
aa = LI()
bb = LI()

dp = [0]*(n+1)
dp[0] = 1

for i, a in enumerate(aa):
    ndp = [0]*(n+1)
    for j in range(i+1):
        pre = dp[j]
        if pre == 0: continue
        ndp[j] = (ndp[j]+pre*(a-1))%md
        ndp[j+1] = (ndp[j+1]+pre)%md
    dp = ndp

for b in bb: print(dp[b])
0