結果

問題 No.1645 AB's abs
ユーザー erbowlerbowl
提出日時 2022-08-29 22:41:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 805 bytes
コンパイル時間 2,173 ms
コンパイル使用メモリ 198,896 KB
実行使用メモリ 19,712 KB
最終ジャッジ日時 2024-04-24 11:50:51
合計ジャッジ時間 3,522 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 7 ms
8,320 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 8 ms
9,984 KB
testcase_09 AC 8 ms
9,728 KB
testcase_10 AC 7 ms
9,088 KB
testcase_11 AC 7 ms
9,216 KB
testcase_12 AC 7 ms
9,472 KB
testcase_13 AC 17 ms
19,200 KB
testcase_14 AC 16 ms
18,432 KB
testcase_15 AC 16 ms
19,200 KB
testcase_16 AC 17 ms
18,560 KB
testcase_17 AC 17 ms
19,072 KB
testcase_18 AC 17 ms
18,560 KB
testcase_19 AC 17 ms
19,200 KB
testcase_20 AC 15 ms
18,048 KB
testcase_21 AC 16 ms
18,816 KB
testcase_22 AC 17 ms
19,200 KB
testcase_23 AC 17 ms
19,584 KB
testcase_24 AC 16 ms
19,584 KB
testcase_25 AC 17 ms
19,712 KB
testcase_26 AC 17 ms
19,712 KB
testcase_27 AC 17 ms
19,584 KB
testcase_28 AC 17 ms
19,584 KB
testcase_29 AC 17 ms
19,712 KB
testcase_30 AC 16 ms
19,712 KB
testcase_31 AC 17 ms
19,584 KB
testcase_32 AC 17 ms
19,584 KB
testcase_33 AC 17 ms
19,584 KB
testcase_34 AC 17 ms
19,712 KB
testcase_35 AC 16 ms
19,584 KB
testcase_36 AC 16 ms
19,584 KB
testcase_37 AC 18 ms
19,712 KB
testcase_38 AC 17 ms
19,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
#define int long long

const ll MOD = 998244353;

signed main(){
    ll n;
    std::cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    vector<vector<ll>> dp(n+1,vector<ll>(20010));
    dp[0][10000] = 1;
    
    for (int i = 0; i < n; i++) {
        for (int j = -10000; j <= 10000; j++) {
            if(j+10000-a[i]>=0)dp[i+1][j+10000] += dp[i][j+10000-a[i]];
            if(j+10000+a[i]<=20000)dp[i+1][j+10000] += dp[i][j+10000+a[i]];
            dp[i+1][j+10000]%=MOD;
        }
    }
    ll ans = 0;
    for (int i = -10000; i <= 10000; i++) {
        ans += (abs(i)+MOD)%MOD*dp[n][i+10000]%MOD;
        ans %= MOD;
    }
    std::cout << ans << std::endl;
}
0