結果

問題 No.1645 AB's abs
ユーザー Drice27149Drice27149
提出日時 2021-08-13 21:40:38
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 673 bytes
コンパイル時間 508 ms
コンパイル使用メモリ 65,276 KB
実行使用メモリ 19,828 KB
最終ジャッジ日時 2024-04-14 17:16:05
合計ジャッジ時間 2,112 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,816 KB
testcase_01 AC 3 ms
6,940 KB
testcase_02 AC 7 ms
9,748 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 4 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 8 ms
9,864 KB
testcase_09 AC 8 ms
11,044 KB
testcase_10 AC 7 ms
9,728 KB
testcase_11 AC 8 ms
10,976 KB
testcase_12 AC 8 ms
11,128 KB
testcase_13 AC 16 ms
19,188 KB
testcase_14 AC 15 ms
18,248 KB
testcase_15 AC 16 ms
19,052 KB
testcase_16 AC 15 ms
18,640 KB
testcase_17 AC 16 ms
19,460 KB
testcase_18 AC 15 ms
18,492 KB
testcase_19 AC 16 ms
18,996 KB
testcase_20 AC 14 ms
18,248 KB
testcase_21 AC 15 ms
18,620 KB
testcase_22 AC 16 ms
18,888 KB
testcase_23 AC 16 ms
19,452 KB
testcase_24 AC 16 ms
19,536 KB
testcase_25 AC 17 ms
19,340 KB
testcase_26 AC 15 ms
19,176 KB
testcase_27 AC 16 ms
19,404 KB
testcase_28 AC 16 ms
19,316 KB
testcase_29 AC 16 ms
19,456 KB
testcase_30 AC 16 ms
19,340 KB
testcase_31 AC 17 ms
19,528 KB
testcase_32 AC 17 ms
19,424 KB
testcase_33 AC 17 ms
19,828 KB
testcase_34 AC 16 ms
19,216 KB
testcase_35 AC 17 ms
19,612 KB
testcase_36 AC 17 ms
19,520 KB
testcase_37 AC 16 ms
19,260 KB
testcase_38 AC 16 ms
19,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
using std::string;
const long long mod = 998244353;
long long f[105][20005];
//int a[105];

int main(){
	int n;
	scanf("%d",&n);
	int off = 10001;
	f[0][off] = 1;
	long long ans = 0;
	for(int i = 1; i <= n; i++){
		int u;
		scanf("%d",&u);
		for(int j = -10000; j <= 10000; j++){
			f[i][j+off] = 0;
			int last = j-u;
			if(last>=-10000) f[i][j+off] += f[i-1][last+off];
			f[i][j+off] %= mod;
			last = j+u;
			if(last<=10000) f[i][j+off] += f[i-1][last+off];
			f[i][j+off] %= mod;
			if(i==n){
				long long val = j;
				if(j<0) val *= -1;
				ans = (ans + val*f[i][j+off]%mod)%mod;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}
0