結果

問題 No.1645 AB's abs
ユーザー tktk_snsntktk_snsn
提出日時 2021-08-13 21:30:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 400 bytes
コンパイル時間 404 ms
コンパイル使用メモリ 82,404 KB
実行使用メモリ 81,932 KB
最終ジャッジ日時 2024-04-14 16:48:47
合計ジャッジ時間 3,976 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,516 KB
testcase_01 AC 36 ms
53,072 KB
testcase_02 AC 55 ms
70,188 KB
testcase_03 AC 34 ms
52,528 KB
testcase_04 AC 36 ms
52,780 KB
testcase_05 AC 35 ms
54,188 KB
testcase_06 AC 45 ms
62,852 KB
testcase_07 AC 41 ms
53,704 KB
testcase_08 AC 58 ms
70,500 KB
testcase_09 AC 59 ms
71,392 KB
testcase_10 AC 56 ms
70,152 KB
testcase_11 AC 56 ms
69,892 KB
testcase_12 AC 57 ms
70,356 KB
testcase_13 AC 71 ms
80,328 KB
testcase_14 AC 67 ms
79,236 KB
testcase_15 AC 69 ms
80,000 KB
testcase_16 AC 69 ms
80,844 KB
testcase_17 AC 70 ms
80,044 KB
testcase_18 AC 68 ms
78,920 KB
testcase_19 AC 68 ms
81,200 KB
testcase_20 AC 69 ms
80,036 KB
testcase_21 AC 68 ms
79,440 KB
testcase_22 AC 69 ms
80,796 KB
testcase_23 AC 70 ms
81,932 KB
testcase_24 AC 70 ms
81,236 KB
testcase_25 AC 69 ms
80,232 KB
testcase_26 AC 70 ms
80,200 KB
testcase_27 AC 70 ms
80,384 KB
testcase_28 AC 71 ms
81,892 KB
testcase_29 AC 71 ms
80,360 KB
testcase_30 AC 70 ms
80,304 KB
testcase_31 AC 72 ms
80,480 KB
testcase_32 AC 73 ms
80,416 KB
testcase_33 AC 73 ms
81,112 KB
testcase_34 AC 73 ms
80,516 KB
testcase_35 AC 75 ms
80,380 KB
testcase_36 AC 74 ms
80,528 KB
testcase_37 AC 76 ms
80,932 KB
testcase_38 AC 73 ms
80,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
U = 100 * 100 * 2 + 10

N = int(input())
A = list(map(int, input().split()))
S = 0

dp = [0] * U
dp[0] = 1
for a in A:
    ndp = [0] * U
    for i in range(-S, S+1):
        ndp[i + a] += dp[i]
        ndp[i - a] += dp[i]
        ndp[i + a] %= mod
        ndp[i - a] %= mod
    S += a
    dp = ndp

ans = 0
for i in range(-S, S+1):
    ans += abs(i) * dp[i]
    ans %= mod
print(ans)
0