結果

問題 No.1353 Limited Sequence
ユーザー SSRSSSRS
提出日時 2021-01-17 13:28:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 152 ms / 2,000 ms
コード長 896 bytes
コンパイル時間 1,767 ms
コンパイル使用メモリ 172,944 KB
実行使用メモリ 34,688 KB
最終ジャッジ日時 2024-05-07 01:59:38
合計ジャッジ時間 5,794 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 59 ms
16,256 KB
testcase_13 AC 59 ms
12,160 KB
testcase_14 AC 15 ms
11,520 KB
testcase_15 AC 41 ms
20,096 KB
testcase_16 AC 5 ms
5,504 KB
testcase_17 AC 9 ms
8,576 KB
testcase_18 AC 59 ms
16,384 KB
testcase_19 AC 86 ms
27,136 KB
testcase_20 AC 18 ms
10,624 KB
testcase_21 AC 5 ms
5,376 KB
testcase_22 AC 7 ms
7,168 KB
testcase_23 AC 55 ms
14,720 KB
testcase_24 AC 35 ms
10,624 KB
testcase_25 AC 76 ms
22,400 KB
testcase_26 AC 32 ms
12,160 KB
testcase_27 AC 17 ms
6,912 KB
testcase_28 AC 19 ms
12,928 KB
testcase_29 AC 11 ms
5,376 KB
testcase_30 AC 42 ms
9,728 KB
testcase_31 AC 25 ms
9,344 KB
testcase_32 AC 23 ms
15,232 KB
testcase_33 AC 7 ms
8,064 KB
testcase_34 AC 39 ms
21,248 KB
testcase_35 AC 10 ms
9,216 KB
testcase_36 AC 12 ms
9,856 KB
testcase_37 AC 143 ms
34,560 KB
testcase_38 AC 133 ms
34,560 KB
testcase_39 AC 138 ms
34,560 KB
testcase_40 AC 146 ms
34,560 KB
testcase_41 AC 150 ms
34,688 KB
testcase_42 AC 144 ms
34,688 KB
testcase_43 AC 152 ms
34,560 KB
testcase_44 AC 148 ms
34,688 KB
testcase_45 AC 141 ms
34,688 KB
testcase_46 AC 151 ms
34,560 KB
testcase_47 AC 71 ms
34,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
int main(){
  int N, L, R;
  cin >> N >> L >> R;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<vector<long long>> dp(R + 1, vector<long long>(N, 0));
  for (int i = 1; i <= N; i++){
    for (int j = 1; i * j <= R && j <= A[i - 1]; j++){
      dp[i * j][i - 1] = 1;
    }
  }
  for (int i = 1; i <= R; i++){
    long long sum = 0;
    for (int j = 0; j < N; j++){
      sum += dp[i][j];
    }
    for (int j = 1; j <= N; j++){
      long long m = (sum - dp[i][j - 1]) % MOD;
      for (int k = 1; i + j * k <= R && k <= A[j - 1]; k++){
        dp[i + j * k][j - 1] += m;
        dp[i + j * k][j - 1] %= MOD;
      }
    }
  }
  long long ans = 0;
  for (int i = L; i <= R; i++){
    for (int j = 0; j < N; j++){
      ans += dp[i][j];
    }
  }
  ans %= MOD;
  cout << ans << endl;
}
0