結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー uni_pythonuni_python
提出日時 2020-10-07 23:09:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 753 ms / 2,000 ms
コード長 653 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 87,080 KB
実行使用メモリ 77,204 KB
最終ジャッジ日時 2023-09-27 10:10:13
合計ジャッジ時間 7,785 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,376 KB
testcase_01 AC 73 ms
71,384 KB
testcase_02 AC 75 ms
71,388 KB
testcase_03 AC 75 ms
71,384 KB
testcase_04 AC 75 ms
71,264 KB
testcase_05 AC 74 ms
71,544 KB
testcase_06 AC 76 ms
71,456 KB
testcase_07 AC 74 ms
71,160 KB
testcase_08 AC 332 ms
77,020 KB
testcase_09 AC 78 ms
75,576 KB
testcase_10 AC 732 ms
77,188 KB
testcase_11 AC 222 ms
77,044 KB
testcase_12 AC 192 ms
77,096 KB
testcase_13 AC 227 ms
77,100 KB
testcase_14 AC 234 ms
77,016 KB
testcase_15 AC 515 ms
77,204 KB
testcase_16 AC 146 ms
77,100 KB
testcase_17 AC 157 ms
76,992 KB
testcase_18 AC 478 ms
77,096 KB
testcase_19 AC 218 ms
77,000 KB
testcase_20 AC 76 ms
75,508 KB
testcase_21 AC 386 ms
76,988 KB
testcase_22 AC 76 ms
75,340 KB
testcase_23 AC 74 ms
71,164 KB
testcase_24 AC 72 ms
71,388 KB
testcase_25 AC 753 ms
77,068 KB
testcase_26 AC 749 ms
77,016 KB
権限があれば一括ダウンロードができます

ソースコード

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)
    # dp[i][j]はiまで見て,j個だけ色1の玉を持つ
    
    dp[0]=1
    
    for i in range(N):
        for j in range(N-1,-1,-1):
            dp[j+1]=(
                dp[j]+
                dp[j+1]*(A[i]-1)
            )%mod
        dp[0]=(dp[0] * (A[i]-1))%mod
        # print(dp)
            

            
            
    for i in range(Q):
        j=B[i]
        print(dp[j])
    


main()
0