結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー imoni_kawaiiimoni_kawaii
提出日時 2020-06-08 22:17:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 777 ms / 2,000 ms
コード長 883 bytes
コンパイル時間 1,903 ms
コンパイル使用メモリ 198,716 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-27 05:10:31
合計ジャッジ時間 7,836 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 282 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 749 ms
4,380 KB
testcase_11 AC 158 ms
4,380 KB
testcase_12 AC 119 ms
4,376 KB
testcase_13 AC 164 ms
4,376 KB
testcase_14 AC 173 ms
4,376 KB
testcase_15 AC 498 ms
4,380 KB
testcase_16 AC 69 ms
4,376 KB
testcase_17 AC 81 ms
4,380 KB
testcase_18 AC 457 ms
4,376 KB
testcase_19 AC 153 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 347 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 777 ms
4,376 KB
testcase_26 AC 771 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
template<class T, class U> inline bool chmax(T &a, const U &b) { if(a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if(a > b) { a = b; return true; } return false; }

ll MOD = 998244353;
int n, q, a[200000];
ll dp[2][6010];

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  cin >> n >> q;
  rep(i, n) cin >> a[i];
  dp[0][0] = 1;
  rep(i, n) {
    rep(j, n+1) {
      dp[1][j] += dp[0][j]*(a[i]-1);
      dp[1][j] %= MOD;
      dp[1][j+1] += dp[0][j];
      dp[1][j+1] %= MOD;
    }
    rep(j, n+1) dp[0][j] = dp[1][j], dp[1][j] = 0;
  }
  rep(qi, q) {
    int b;
    cin >> b;
    cout << dp[0][b] << '\n';
  }
  return 0;
}
0