結果

問題 No.1353 Limited Sequence
ユーザー Example0911Example0911
提出日時 2021-01-29 18:33:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 884 ms / 2,000 ms
コード長 828 bytes
コンパイル時間 2,012 ms
コンパイル使用メモリ 202,032 KB
実行使用メモリ 26,332 KB
最終ジャッジ日時 2023-09-09 12:12:48
合計ジャッジ時間 19,094 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 3 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 419 ms
18,876 KB
testcase_13 AC 616 ms
18,584 KB
testcase_14 AC 52 ms
7,308 KB
testcase_15 AC 214 ms
12,724 KB
testcase_16 AC 17 ms
5,120 KB
testcase_17 AC 30 ms
5,896 KB
testcase_18 AC 447 ms
18,784 KB
testcase_19 AC 580 ms
21,328 KB
testcase_20 AC 127 ms
10,116 KB
testcase_21 AC 42 ms
6,804 KB
testcase_22 AC 38 ms
6,368 KB
testcase_23 AC 462 ms
18,180 KB
testcase_24 AC 327 ms
14,828 KB
testcase_25 AC 521 ms
20,748 KB
testcase_26 AC 277 ms
14,004 KB
testcase_27 AC 176 ms
11,008 KB
testcase_28 AC 79 ms
8,240 KB
testcase_29 AC 125 ms
9,944 KB
testcase_30 AC 489 ms
16,140 KB
testcase_31 AC 247 ms
13,148 KB
testcase_32 AC 65 ms
16,248 KB
testcase_33 AC 16 ms
7,352 KB
testcase_34 AC 110 ms
23,724 KB
testcase_35 AC 39 ms
11,984 KB
testcase_36 AC 49 ms
14,328 KB
testcase_37 AC 873 ms
26,332 KB
testcase_38 AC 804 ms
26,012 KB
testcase_39 AC 805 ms
26,048 KB
testcase_40 AC 884 ms
26,228 KB
testcase_41 AC 868 ms
26,044 KB
testcase_42 AC 809 ms
26,088 KB
testcase_43 AC 872 ms
26,112 KB
testcase_44 AC 867 ms
26,088 KB
testcase_45 AC 827 ms
26,148 KB
testcase_46 AC 882 ms
26,028 KB
testcase_47 AC 140 ms
26,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using P = pair<ll, ll>;
const ll INF = (1LL << 61);
ll mod = 998244353;
ll dp[2010][2010];
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N, L, R; cin >> N >> L >> R;
	vector<ll>A(N+1); for (int i = 1; i <= N; i++)cin >> A[i];
	vector<ll>sum(R + 1);
	dp[0][0] = 1;
	sum[0] = 1;
	for (int i = 1; i <= R; i++) {
		for (int j = 1; j <= N; j++) {
			for (int k = 1; k * j <= i && k <= A[j]; k++) {
				dp[i][j] += sum[i - k * j]; dp[i][j] %= mod;
				dp[i][j] -= dp[i - k * j][j]; dp[i][j] += mod; dp[i][j] %= mod;
				sum[i] += sum[i - k * j]; sum[i] %= mod;
				sum[i] -= dp[i - k * j][j]; sum[i] += mod; sum[i] %= mod;
			}
		}
	}
	ll ans = 0;
	for (int i = L; i <= R; i++) {
		ans += sum[i];
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}
0