結果

問題 No.1645 AB's abs
ユーザー ぷらぷら
提出日時 2021-08-13 21:29:51
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 608 bytes
コンパイル時間 1,747 ms
コンパイル使用メモリ 193,560 KB
最終ジャッジ日時 2025-01-23 18:16:16
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 WA * 26
権限があれば一括ダウンロードができます

ソースコード

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