結果

問題 No.1353 Limited Sequence
ユーザー SSRSSSRS
提出日時 2021-01-17 13:28:45
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 896 bytes
コンパイル時間 2,019 ms
コンパイル使用メモリ 172,488 KB
実行使用メモリ 34,568 KB
最終ジャッジ日時 2023-08-19 19:04:13
合計ジャッジ時間 5,792 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,500 KB
testcase_12 AC 59 ms
16,232 KB
testcase_13 AC 62 ms
12,060 KB
testcase_14 AC 15 ms
11,528 KB
testcase_15 AC 42 ms
19,984 KB
testcase_16 AC 5 ms
5,548 KB
testcase_17 AC 10 ms
8,312 KB
testcase_18 AC 60 ms
16,240 KB
testcase_19 AC 87 ms
27,112 KB
testcase_20 AC 18 ms
10,428 KB
testcase_21 AC 6 ms
4,752 KB
testcase_22 AC 9 ms
7,004 KB
testcase_23 AC 54 ms
14,332 KB
testcase_24 AC 35 ms
10,436 KB
testcase_25 AC 75 ms
22,440 KB
testcase_26 AC 32 ms
11,700 KB
testcase_27 AC 17 ms
7,032 KB
testcase_28 AC 18 ms
12,752 KB
testcase_29 AC 11 ms
4,976 KB
testcase_30 AC 44 ms
9,732 KB
testcase_31 AC 27 ms
9,124 KB
testcase_32 AC 21 ms
14,872 KB
testcase_33 AC 7 ms
8,064 KB
testcase_34 AC 37 ms
21,036 KB
testcase_35 AC 13 ms
9,372 KB
testcase_36 AC 13 ms
9,636 KB
testcase_37 AC 145 ms
34,408 KB
testcase_38 AC 137 ms
34,400 KB
testcase_39 AC 138 ms
34,400 KB
testcase_40 AC 138 ms
34,516 KB
testcase_41 AC 146 ms
34,468 KB
testcase_42 AC 134 ms
34,524 KB
testcase_43 AC 139 ms
34,568 KB
testcase_44 AC 141 ms
34,416 KB
testcase_45 AC 142 ms
34,412 KB
testcase_46 AC 142 ms
34,448 KB
testcase_47 AC 59 ms
34,464 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