結果

問題 No.1645 AB's abs
ユーザー charmychachachacharmychachacha
提出日時 2021-08-13 21:42:46
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 8 ms / 2,000 ms
コード長 588 bytes
コンパイル時間 1,777 ms
コンパイル使用メモリ 162,912 KB
実行使用メモリ 11,868 KB
最終ジャッジ日時 2024-04-14 17:20:11
合計ジャッジ時間 3,454 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
11,780 KB
testcase_01 AC 6 ms
11,848 KB
testcase_02 AC 5 ms
11,800 KB
testcase_03 AC 5 ms
11,764 KB
testcase_04 AC 5 ms
11,804 KB
testcase_05 AC 5 ms
11,748 KB
testcase_06 AC 5 ms
11,788 KB
testcase_07 AC 5 ms
11,868 KB
testcase_08 AC 5 ms
11,832 KB
testcase_09 AC 5 ms
11,664 KB
testcase_10 AC 5 ms
11,756 KB
testcase_11 AC 5 ms
11,848 KB
testcase_12 AC 5 ms
11,720 KB
testcase_13 AC 7 ms
11,844 KB
testcase_14 AC 7 ms
11,804 KB
testcase_15 AC 6 ms
11,736 KB
testcase_16 AC 6 ms
11,660 KB
testcase_17 AC 7 ms
11,620 KB
testcase_18 AC 6 ms
11,728 KB
testcase_19 AC 6 ms
11,644 KB
testcase_20 AC 6 ms
11,688 KB
testcase_21 AC 6 ms
11,708 KB
testcase_22 AC 7 ms
11,748 KB
testcase_23 AC 7 ms
11,640 KB
testcase_24 AC 7 ms
11,680 KB
testcase_25 AC 6 ms
11,652 KB
testcase_26 AC 7 ms
11,692 KB
testcase_27 AC 6 ms
11,748 KB
testcase_28 AC 6 ms
11,792 KB
testcase_29 AC 6 ms
11,860 KB
testcase_30 AC 5 ms
11,852 KB
testcase_31 AC 7 ms
11,580 KB
testcase_32 AC 6 ms
11,656 KB
testcase_33 AC 8 ms
11,656 KB
testcase_34 AC 6 ms
11,672 KB
testcase_35 AC 7 ms
11,676 KB
testcase_36 AC 7 ms
11,824 KB
testcase_37 AC 6 ms
11,712 KB
testcase_38 AC 6 ms
11,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; int A[110]; 
	cin >> N;
	long long sum = 0;
	for(int i = 0; i < N; i++){
		cin >> A[i]; sum += A[i]; 
	}
	long long mod = 998244353;
	long long dp[105][10010] = {}; 
	dp[0][0] = 1; 
	for(int i = 0; i < N; i++){
		for(int j = 0; j <= 100*i; j++){
			dp[i+1][j] += dp[i][j]; 
			dp[i+1][j] %= mod; 
			dp[i+1][j+A[i]] += dp[i][j]; 
			dp[i+1][j+A[i]] %= mod;
		}
	}
	long long ans = 0; 
	for(int i = 0; i <= 100 * N; i++){
		long long a = abs(sum - i * 2);
		ans += a * dp[N][i] % mod; ans %= mod;
	}
	cout << ans << "\n";
}
0