結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー uni_pythonuni_python
提出日時 2020-10-07 23:02:34
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 669 bytes
コンパイル時間 762 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 360,408 KB
最終ジャッジ日時 2023-09-27 10:09:43
合計ジャッジ時間 10,853 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,268 KB
testcase_01 AC 66 ms
71,484 KB
testcase_02 AC 66 ms
71,240 KB
testcase_03 AC 62 ms
71,552 KB
testcase_04 AC 65 ms
71,444 KB
testcase_05 AC 65 ms
71,268 KB
testcase_06 AC 67 ms
71,624 KB
testcase_07 AC 67 ms
71,252 KB
testcase_08 MLE -
testcase_09 AC 70 ms
75,696 KB
testcase_10 MLE -
testcase_11 MLE -
testcase_12 AC 221 ms
113,240 KB
testcase_13 MLE -
testcase_14 MLE -
testcase_15 MLE -
testcase_16 AC 157 ms
90,964 KB
testcase_17 AC 173 ms
91,052 KB
testcase_18 MLE -
testcase_19 MLE -
testcase_20 AC 66 ms
75,624 KB
testcase_21 MLE -
testcase_22 AC 70 ms
75,772 KB
testcase_23 AC 63 ms
71,584 KB
testcase_24 AC 65 ms
71,428 KB
testcase_25 MLE -
testcase_26 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=998244353
    N,Q=MI()
    A=LI()
    B=LI()
    
    dp=[[0]*(N+1)for _ in range(N+1)]
    # dp[i][j]はiまで見て,j個だけ色1の玉を持つ
    
    dp[0][0]=1
    for i in range(N):
        dp[i+1][0]=(dp[i][0] * (A[i]-1) )%mod
    
    for i in range(N):
        for j in range(N):
            dp[i+1][j+1]=(
                dp[i][j]+
                dp[i][j+1]*(A[i]-1)
            )%mod
            
    for i in range(Q):
        j=B[i]
        print(dp[-1][j])
    


main()
0