結果

問題 No.1645 AB's abs
ユーザー ace_amuroace_amuro
提出日時 2023-04-13 15:41:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 739 bytes
コンパイル時間 643 ms
コンパイル使用メモリ 82,400 KB
実行使用メモリ 19,200 KB
最終ジャッジ日時 2024-04-17 19:11:07
合計ジャッジ時間 2,450 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 8 ms
8,448 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 10 ms
9,856 KB
testcase_09 AC 11 ms
9,600 KB
testcase_10 AC 10 ms
8,960 KB
testcase_11 AC 11 ms
8,960 KB
testcase_12 AC 10 ms
9,216 KB
testcase_13 AC 24 ms
18,944 KB
testcase_14 AC 22 ms
17,920 KB
testcase_15 AC 23 ms
18,944 KB
testcase_16 AC 23 ms
18,176 KB
testcase_17 AC 23 ms
18,688 KB
testcase_18 AC 22 ms
18,048 KB
testcase_19 AC 23 ms
18,944 KB
testcase_20 AC 22 ms
17,536 KB
testcase_21 AC 23 ms
18,304 KB
testcase_22 AC 25 ms
18,816 KB
testcase_23 AC 26 ms
19,072 KB
testcase_24 AC 27 ms
19,072 KB
testcase_25 AC 25 ms
19,072 KB
testcase_26 AC 25 ms
19,200 KB
testcase_27 AC 24 ms
19,072 KB
testcase_28 AC 25 ms
19,200 KB
testcase_29 AC 24 ms
19,200 KB
testcase_30 AC 23 ms
19,200 KB
testcase_31 AC 26 ms
19,072 KB
testcase_32 AC 24 ms
19,072 KB
testcase_33 AC 25 ms
19,200 KB
testcase_34 AC 25 ms
19,200 KB
testcase_35 AC 24 ms
19,200 KB
testcase_36 AC 25 ms
19,200 KB
testcase_37 AC 25 ms
19,200 KB
testcase_38 AC 24 ms
19,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<ctime>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
using namespace std;
typedef long long LL;
const int Z=1e4;
const int MOD=998244353;
int n;
int a[101];
LL dp[101][2*Z+1];
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    dp[0][Z]=1;
    for(int i=1;i<=n;i++){
        for(int j=-Z;j<=Z;j++){
            if(j-a[i]>=-Z) dp[i][Z+j]+=dp[i-1][Z+j-a[i]];
            if(j+a[i]<=Z) dp[i][Z+j]+=dp[i-1][Z+j+a[i]];
            dp[i][Z+j]%=MOD;
        }
    }
    LL ans=0;
    for(int j=-Z;j<=Z;j++){
        ans+=abs(j)*dp[n][Z+j];
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}
0