結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー Naoto FujiwaraNaoto Fujiwara
提出日時 2023-05-31 14:33:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 862 bytes
コンパイル時間 771 ms
コンパイル使用メモリ 85,952 KB
実行使用メモリ 285,008 KB
最終ジャッジ日時 2023-08-28 01:31:51
合計ジャッジ時間 4,483 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 113 ms
104,912 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 MLE -
testcase_11 AC 63 ms
60,176 KB
testcase_12 AC 49 ms
45,788 KB
testcase_13 AC 70 ms
61,896 KB
testcase_14 AC 69 ms
65,316 KB
testcase_15 MLE -
testcase_16 AC 29 ms
27,732 KB
testcase_17 AC 33 ms
31,920 KB
testcase_18 MLE -
testcase_19 AC 62 ms
57,884 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 MLE -
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,384 KB
testcase_25 MLE -
testcase_26 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<int,int> P;
typedef pair<int,P> PP;
const ll MOD=998244353;

int main(){
    int N,Q;
    cin>>N>>Q;
    vector<ll> A(N),B(Q);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int i=0;i<Q;i++){
        cin>>B[i];
    }

    vector<vector<ll>> dp(N+1,vector<ll>(N+2,0));

    dp[0][0]=1;//0個の箱から0個の1の玉
    for(int i=0;i<N;i++){
        for(int j=0;j<=i;j++){
            dp[i+1][j+1]+=dp[i][j];
            dp[i+1][j+1]%=MOD;

            dp[i+1][j]+=dp[i][j]*(A[i]-1)%MOD;
            dp[i+1][j]%=MOD;
        }
    }

    for(int q=0;q<Q;q++){
        cout<<dp[N][B[q]]<<endl;
    }
    

}
0