結果

問題 No.1645 AB's abs
ユーザー 夜
提出日時 2021-08-13 21:36:59
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 781 bytes
コンパイル時間 974 ms
コンパイル使用メモリ 94,760 KB
実行使用メモリ 19,200 KB
最終ジャッジ日時 2024-04-14 17:06:44
合計ジャッジ時間 4,098 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,812 KB
testcase_01 AC 3 ms
6,940 KB
testcase_02 AC 19 ms
8,192 KB
testcase_03 AC 3 ms
6,944 KB
testcase_04 AC 3 ms
6,940 KB
testcase_05 AC 5 ms
6,944 KB
testcase_06 AC 8 ms
6,944 KB
testcase_07 AC 4 ms
6,940 KB
testcase_08 AC 25 ms
9,728 KB
testcase_09 AC 23 ms
9,728 KB
testcase_10 AC 21 ms
8,908 KB
testcase_11 AC 22 ms
8,960 KB
testcase_12 AC 23 ms
9,088 KB
testcase_13 AC 58 ms
18,816 KB
testcase_14 AC 55 ms
18,048 KB
testcase_15 AC 57 ms
19,016 KB
testcase_16 AC 56 ms
18,176 KB
testcase_17 AC 58 ms
18,688 KB
testcase_18 AC 56 ms
18,176 KB
testcase_19 AC 57 ms
18,944 KB
testcase_20 AC 54 ms
17,664 KB
testcase_21 AC 56 ms
18,304 KB
testcase_22 AC 57 ms
18,688 KB
testcase_23 AC 60 ms
19,072 KB
testcase_24 AC 59 ms
19,072 KB
testcase_25 AC 57 ms
19,072 KB
testcase_26 AC 59 ms
19,200 KB
testcase_27 AC 60 ms
19,200 KB
testcase_28 AC 60 ms
19,200 KB
testcase_29 AC 60 ms
19,072 KB
testcase_30 AC 58 ms
19,200 KB
testcase_31 AC 58 ms
19,200 KB
testcase_32 AC 60 ms
19,200 KB
testcase_33 AC 59 ms
19,200 KB
testcase_34 AC 58 ms
19,200 KB
testcase_35 AC 58 ms
19,200 KB
testcase_36 AC 60 ms
19,200 KB
testcase_37 AC 60 ms
19,200 KB
testcase_38 AC 59 ms
19,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long dp[110][20010] = {};
long long a[110];
long long mod = 998244353;
int main() {
	int n;
	cin >> n;
	dp[0][10000] = 1;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		for (int j = a[i]; j <= 20000 - a[i]; j++) {
			dp[i + 1][j - a[i]] += dp[i][j];
			dp[i + 1][j + a[i]] += dp[i][j];
			dp[i + 1][j + a[i]] %= mod;
			dp[i + 1][j - a[i]] %= mod;
		}
	}
	long long ans = 0;
	for (int i = 0; i <= 20000; i++) {
		ans += dp[n][i] * abs(i - 10000);
		ans %= mod;
	}
	cout << ans << endl;
}
0