結果

問題 No.1645 AB's abs
ユーザー ぷらぷら
提出日時 2021-08-13 21:29:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 608 bytes
コンパイル時間 2,769 ms
コンパイル使用メモリ 195,148 KB
実行使用メモリ 28,236 KB
最終ジャッジ日時 2024-04-14 16:46:44
合計ジャッジ時間 3,549 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 5 ms
9,732 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 3 ms
6,944 KB
testcase_06 AC 3 ms
6,944 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 6 ms
11,876 KB
testcase_09 AC 6 ms
11,904 KB
testcase_10 AC 5 ms
11,748 KB
testcase_11 AC 5 ms
11,900 KB
testcase_12 AC 6 ms
11,732 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

constexpr int mod = 998244353;
long long dp[105][30005];

int main() {
    int N;
    cin >> N;
    vector<int>A(N);
    dp[0][15000] = 1;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        for(int j = 0; j <= 30000; j++) {
            if(dp[i][j] == 0) {
                continue;
            }
            dp[i+1][j+A[i]] += dp[i][j];
            dp[i+1][j-A[i]] += dp[i][j];
        }
    }
    long long ans = 0;
    for(int i = 0; i <= 30000; i++) {
        ans += dp[N][i]*abs(i-15000)%mod;
        ans %= mod;
    }
    cout << ans << endl;
}
0