結果

問題 No.1645 AB's abs
ユーザー atjh16atjh16
提出日時 2021-09-23 16:54:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 529 bytes
コンパイル時間 1,558 ms
コンパイル使用メモリ 164,992 KB
実行使用メモリ 19,212 KB
最終ジャッジ日時 2023-09-18 19:54:33
合計ジャッジ時間 3,856 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 10 ms
8,056 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 4 ms
4,592 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 12 ms
9,704 KB
testcase_09 AC 12 ms
9,472 KB
testcase_10 AC 11 ms
8,804 KB
testcase_11 AC 11 ms
8,820 KB
testcase_12 AC 11 ms
8,924 KB
testcase_13 AC 27 ms
18,764 KB
testcase_14 AC 25 ms
17,660 KB
testcase_15 AC 27 ms
18,760 KB
testcase_16 AC 26 ms
17,972 KB
testcase_17 AC 27 ms
18,444 KB
testcase_18 AC 25 ms
17,956 KB
testcase_19 AC 27 ms
18,620 KB
testcase_20 AC 24 ms
17,580 KB
testcase_21 AC 25 ms
18,168 KB
testcase_22 AC 27 ms
18,524 KB
testcase_23 AC 28 ms
18,904 KB
testcase_24 AC 28 ms
18,900 KB
testcase_25 AC 28 ms
18,972 KB
testcase_26 AC 27 ms
18,956 KB
testcase_27 AC 28 ms
19,016 KB
testcase_28 AC 28 ms
18,988 KB
testcase_29 AC 28 ms
19,020 KB
testcase_30 AC 28 ms
18,924 KB
testcase_31 AC 28 ms
18,976 KB
testcase_32 AC 27 ms
18,964 KB
testcase_33 AC 27 ms
18,988 KB
testcase_34 AC 28 ms
18,956 KB
testcase_35 AC 27 ms
18,928 KB
testcase_36 AC 28 ms
19,048 KB
testcase_37 AC 28 ms
18,984 KB
testcase_38 AC 28 ms
19,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int n, a;
const int N = 20001;
long long m = 0;
long long dp[101][N];
const long long M = 998244353;

int main()
{
	cin >> n;

	dp[0][10000] = 1;

	for (int i = 1; i <= n; i++) {
		cin >> a;

		for (int j = 0; j < N; j++) {
			if (j >= a)
				dp[i][j] = (dp[i][j] + dp[i - 1][j - a]) % M;

			if (j <= 20000 - a)
				dp[i][j] = (dp[i][j] + dp[i - 1][j + a]) % M;
		}
	}
	
	for (long long i = 10001; i <= 20000; i++)
		m = (m + dp[n][i] * (i - 10000) * 2) % M;

	cout << m << endl;
}
0