結果

問題 No.1645 AB's abs
ユーザー ytsmashytsmash
提出日時 2021-08-14 15:23:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 1,035 bytes
コンパイル時間 2,167 ms
コンパイル使用メモリ 199,612 KB
実行使用メモリ 19,712 KB
最終ジャッジ日時 2024-04-15 13:23:44
合計ジャッジ時間 3,918 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,816 KB
testcase_01 AC 3 ms
6,940 KB
testcase_02 AC 8 ms
8,448 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 3 ms
6,940 KB
testcase_05 AC 3 ms
6,944 KB
testcase_06 AC 4 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 9 ms
9,856 KB
testcase_09 AC 9 ms
9,728 KB
testcase_10 AC 9 ms
9,088 KB
testcase_11 AC 8 ms
9,088 KB
testcase_12 AC 9 ms
9,344 KB
testcase_13 AC 20 ms
19,200 KB
testcase_14 AC 19 ms
18,432 KB
testcase_15 AC 20 ms
19,328 KB
testcase_16 AC 19 ms
18,560 KB
testcase_17 AC 20 ms
19,200 KB
testcase_18 AC 19 ms
18,432 KB
testcase_19 AC 20 ms
19,200 KB
testcase_20 AC 18 ms
18,048 KB
testcase_21 AC 20 ms
18,560 KB
testcase_22 AC 20 ms
19,072 KB
testcase_23 AC 20 ms
19,712 KB
testcase_24 AC 21 ms
19,712 KB
testcase_25 AC 20 ms
19,584 KB
testcase_26 AC 21 ms
19,584 KB
testcase_27 AC 21 ms
19,712 KB
testcase_28 AC 21 ms
19,584 KB
testcase_29 AC 21 ms
19,712 KB
testcase_30 AC 21 ms
19,584 KB
testcase_31 AC 20 ms
19,584 KB
testcase_32 AC 20 ms
19,584 KB
testcase_33 AC 20 ms
19,584 KB
testcase_34 AC 20 ms
19,712 KB
testcase_35 AC 21 ms
19,712 KB
testcase_36 AC 20 ms
19,584 KB
testcase_37 AC 20 ms
19,584 KB
testcase_38 AC 21 ms
19,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *    author:  ytsmash
 *    created: 14.08.2021 13:34:43
 **/

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) x.begin(), x.end()
const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
using P = pair<int, int>;

int main() {
    const long long MOD = 998244353;
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector<vector<long long>> dp(N + 1, vector<long long>(20001, 0));
    dp[0][10000] = 1;
    for (int i = 0; i < N; i++) {
        for (int j = A[i]; j <= 20000 - A[i]; j++) {
            dp[i + 1][j - A[i]] += dp[i][j];
            dp[i + 1][j - A[i]] %= 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 <= 20000; i++) {
        ans += dp[N][i] * abs(i - 10000);
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}
0