結果

問題 No.1645 AB's abs
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-08-13 21:38:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 560 ms / 2,000 ms
コード長 499 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 82,396 KB
実行使用メモリ 198,356 KB
最終ジャッジ日時 2024-04-14 17:10:59
合計ジャッジ時間 18,418 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
110,368 KB
testcase_01 AC 97 ms
103,812 KB
testcase_02 AC 252 ms
133,324 KB
testcase_03 AC 99 ms
103,120 KB
testcase_04 AC 111 ms
110,216 KB
testcase_05 AC 121 ms
111,240 KB
testcase_06 AC 147 ms
118,908 KB
testcase_07 AC 117 ms
100,044 KB
testcase_08 AC 289 ms
141,168 KB
testcase_09 AC 294 ms
141,788 KB
testcase_10 AC 270 ms
142,928 KB
testcase_11 AC 269 ms
142,760 KB
testcase_12 AC 275 ms
143,504 KB
testcase_13 AC 546 ms
196,956 KB
testcase_14 AC 541 ms
190,124 KB
testcase_15 AC 551 ms
196,816 KB
testcase_16 AC 530 ms
193,756 KB
testcase_17 AC 548 ms
194,876 KB
testcase_18 AC 528 ms
192,036 KB
testcase_19 AC 543 ms
196,188 KB
testcase_20 AC 511 ms
188,980 KB
testcase_21 AC 529 ms
193,072 KB
testcase_22 AC 544 ms
195,036 KB
testcase_23 AC 554 ms
197,488 KB
testcase_24 AC 554 ms
196,100 KB
testcase_25 AC 559 ms
197,000 KB
testcase_26 AC 555 ms
197,276 KB
testcase_27 AC 556 ms
195,948 KB
testcase_28 AC 556 ms
196,964 KB
testcase_29 AC 552 ms
195,944 KB
testcase_30 AC 552 ms
196,868 KB
testcase_31 AC 555 ms
197,304 KB
testcase_32 AC 554 ms
197,064 KB
testcase_33 AC 557 ms
197,160 KB
testcase_34 AC 560 ms
197,232 KB
testcase_35 AC 555 ms
197,044 KB
testcase_36 AC 557 ms
197,472 KB
testcase_37 AC 555 ms
197,120 KB
testcase_38 AC 558 ms
198,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))
dp = [defaultdict(int) for _ in range(n + 10)]
mod = 998244353
dp[0][0] = 1
for i in range(1, n + 1):
    for j in range(-(10 ** 4 + 10), 10 ** 4 + 10):
        dp[i][j + a[i - 1]] += dp[i - 1][j]
        dp[i][j + a[i - 1]] %= mod
        dp[i][j - a[i - 1]] += dp[i - 1][j]
        dp[i][j + a[i - 1]] %= mod
ans = 0
for i in range(-(10 ** 5), 10 ** 5):
    ans += dp[n][i] * abs(i)
    ans %= mod
print(ans)
0