結果

問題 No.1645 AB's abs
ユーザー trineutrontrineutron
提出日時 2021-08-13 21:34:29
言語 C++23(draft)
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 734 bytes
コンパイル時間 3,581 ms
コンパイル使用メモリ 281,596 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-04-14 16:56:26
合計ジャッジ時間 5,308 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 7 ms
6,944 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 3 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 8 ms
6,944 KB
testcase_09 AC 8 ms
6,940 KB
testcase_10 AC 7 ms
6,940 KB
testcase_11 AC 7 ms
6,944 KB
testcase_12 AC 7 ms
6,944 KB
testcase_13 AC 17 ms
11,008 KB
testcase_14 AC 16 ms
10,624 KB
testcase_15 AC 17 ms
11,136 KB
testcase_16 AC 17 ms
10,880 KB
testcase_17 AC 17 ms
10,880 KB
testcase_18 AC 17 ms
10,624 KB
testcase_19 AC 17 ms
11,008 KB
testcase_20 AC 15 ms
10,496 KB
testcase_21 AC 17 ms
10,880 KB
testcase_22 AC 17 ms
11,136 KB
testcase_23 AC 17 ms
11,136 KB
testcase_24 AC 18 ms
11,264 KB
testcase_25 AC 17 ms
11,264 KB
testcase_26 AC 18 ms
11,264 KB
testcase_27 AC 17 ms
11,136 KB
testcase_28 AC 17 ms
11,136 KB
testcase_29 AC 17 ms
11,264 KB
testcase_30 AC 18 ms
11,136 KB
testcase_31 AC 18 ms
11,136 KB
testcase_32 AC 17 ms
11,136 KB
testcase_33 AC 18 ms
11,264 KB
testcase_34 AC 17 ms
11,136 KB
testcase_35 AC 18 ms
11,136 KB
testcase_36 AC 18 ms
11,136 KB
testcase_37 AC 18 ms
11,264 KB
testcase_38 AC 17 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>

using namespace std;
using namespace atcoder;

using mint = modint998244353;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }

    vector dp(n + 1, vector<mint>(20001));
    dp.at(0).at(10000) = 1;
    for (int i = 0; i < n; i++)
    {
        for (int j = a.at(i); j <= 20000 - a.at(i); j++)
        {
            dp.at(i + 1).at(j - a.at(i)) += dp.at(i).at(j);
            dp.at(i + 1).at(j + a.at(i)) += dp.at(i).at(j);
        }
    }

    mint ans = 0;
    for (int i = 0; i <= 20000; i++)
    {
        ans += abs(i - 10000) * dp.at(n).at(i);
    }
    cout << ans.val() << endl;
    return 0;
}
0