結果

問題 No.1645 AB's abs
ユーザー zezerozezero
提出日時 2021-08-14 01:34:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 839 bytes
コンパイル時間 1,059 ms
コンパイル使用メモリ 102,252 KB
実行使用メモリ 19,456 KB
最終ジャッジ日時 2024-04-14 23:06:09
合計ジャッジ時間 2,654 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 9 ms
8,320 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 4 ms
6,940 KB
testcase_07 AC 3 ms
6,948 KB
testcase_08 AC 11 ms
9,600 KB
testcase_09 AC 12 ms
9,600 KB
testcase_10 AC 11 ms
8,960 KB
testcase_11 AC 10 ms
8,960 KB
testcase_12 AC 12 ms
9,088 KB
testcase_13 AC 27 ms
18,944 KB
testcase_14 AC 24 ms
18,048 KB
testcase_15 AC 26 ms
18,816 KB
testcase_16 AC 25 ms
18,176 KB
testcase_17 AC 23 ms
18,944 KB
testcase_18 AC 24 ms
18,176 KB
testcase_19 AC 27 ms
19,072 KB
testcase_20 AC 24 ms
17,792 KB
testcase_21 AC 25 ms
18,432 KB
testcase_22 AC 25 ms
18,688 KB
testcase_23 AC 25 ms
19,268 KB
testcase_24 AC 26 ms
19,328 KB
testcase_25 AC 26 ms
19,328 KB
testcase_26 AC 26 ms
19,328 KB
testcase_27 AC 26 ms
19,456 KB
testcase_28 AC 26 ms
19,328 KB
testcase_29 AC 27 ms
19,456 KB
testcase_30 AC 26 ms
19,200 KB
testcase_31 AC 26 ms
19,328 KB
testcase_32 AC 27 ms
19,328 KB
testcase_33 AC 27 ms
19,200 KB
testcase_34 AC 26 ms
19,200 KB
testcase_35 AC 26 ms
19,200 KB
testcase_36 AC 28 ms
19,200 KB
testcase_37 AC 26 ms
19,200 KB
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)
const ll mod = 998244353;
ll dp[110][20100];
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    dp[0][10001] = 1LL;
    for (int i = 0; i < n;i++){
        for (int j = 1; j <= 20000;j++){
            dp[i+1][min(20001,j+a[i])] += dp[i][j];
            dp[i+1][min(20001,j+a[i])] %= mod;
            dp[i+1][max(0,j-a[i])] += dp[i][j];
            dp[i+1][max(0,j-a[i])] %= mod;
        }
    }
    ll ans = 0;
    for (int i = 1; i <= 20000;i++){
        ans += abs(i-10001)*dp[n][i];
        ans %= mod;
    }
    cout << ans << endl;
    
    

    return 0;
}
0