結果

問題 No.1645 AB's abs
ユーザー karinohitokarinohito
提出日時 2021-08-13 21:41:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 708 bytes
コンパイル時間 1,724 ms
コンパイル使用メモリ 169,276 KB
実行使用メモリ 35,584 KB
最終ジャッジ日時 2024-04-14 17:18:04
合計ジャッジ時間 3,770 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,816 KB
testcase_01 AC 3 ms
6,940 KB
testcase_02 AC 11 ms
13,312 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 3 ms
6,944 KB
testcase_05 AC 4 ms
6,944 KB
testcase_06 AC 4 ms
6,944 KB
testcase_07 AC 3 ms
6,944 KB
testcase_08 AC 14 ms
16,128 KB
testcase_09 AC 14 ms
16,128 KB
testcase_10 AC 13 ms
14,848 KB
testcase_11 AC 13 ms
14,976 KB
testcase_12 AC 13 ms
15,232 KB
testcase_13 AC 32 ms
34,816 KB
testcase_14 AC 30 ms
32,896 KB
testcase_15 AC 32 ms
34,816 KB
testcase_16 AC 31 ms
33,536 KB
testcase_17 AC 31 ms
34,560 KB
testcase_18 AC 30 ms
33,280 KB
testcase_19 AC 31 ms
34,816 KB
testcase_20 AC 29 ms
32,256 KB
testcase_21 AC 31 ms
33,536 KB
testcase_22 AC 32 ms
34,432 KB
testcase_23 AC 32 ms
35,456 KB
testcase_24 AC 33 ms
35,456 KB
testcase_25 AC 33 ms
35,456 KB
testcase_26 AC 32 ms
35,456 KB
testcase_27 AC 33 ms
35,584 KB
testcase_28 AC 33 ms
35,584 KB
testcase_29 AC 32 ms
35,456 KB
testcase_30 AC 33 ms
35,456 KB
testcase_31 AC 32 ms
35,456 KB
testcase_32 AC 33 ms
35,456 KB
testcase_33 AC 33 ms
35,456 KB
testcase_34 AC 33 ms
35,584 KB
testcase_35 AC 33 ms
35,584 KB
testcase_36 AC 33 ms
35,456 KB
testcase_37 AC 33 ms
35,456 KB
testcase_38 AC 32 ms
35,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#include <atcoder/all>
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
//using namespace atcoder;
using ll = long long;
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using Graph = vector<vector<ll>>;



int main() {
	ll N;
	cin>>N;
	vll A(N);
	rep(i,N)cin>>A[i];
	vector<vll> DP(N+1,vll(40000,0));
	DP[0][20000]=1;
	ll mod=998244353;
	rep(i,N){
		rep(j,40000){
			if(DP[i][j]>0){
				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;
			}
		}
	}
	ll an=0;
	rep(i,40000){
		ll p=DP[N][i]*abs(i-20000);
		p%=mod;
		
		an+=p;
		an%=mod;
	}
	cout<<an<<endl;
}
0