結果

問題 No.1645 AB's abs
ユーザー brthyyjpbrthyyjp
提出日時 2021-08-15 17:18:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 393 bytes
コンパイル時間 205 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 79,232 KB
最終ジャッジ日時 2024-04-16 19:49:42
合計ジャッジ時間 5,724 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
53,248 KB
testcase_01 AC 46 ms
53,760 KB
testcase_02 AC 79 ms
71,168 KB
testcase_03 AC 46 ms
53,632 KB
testcase_04 AC 46 ms
53,504 KB
testcase_05 AC 47 ms
53,376 KB
testcase_06 AC 47 ms
54,272 KB
testcase_07 AC 47 ms
53,760 KB
testcase_08 AC 86 ms
73,728 KB
testcase_09 AC 90 ms
76,288 KB
testcase_10 AC 80 ms
72,192 KB
testcase_11 AC 85 ms
74,496 KB
testcase_12 AC 84 ms
73,600 KB
testcase_13 AC 133 ms
76,928 KB
testcase_14 AC 117 ms
76,672 KB
testcase_15 AC 137 ms
76,928 KB
testcase_16 AC 130 ms
76,928 KB
testcase_17 AC 128 ms
76,672 KB
testcase_18 AC 123 ms
76,672 KB
testcase_19 AC 127 ms
76,672 KB
testcase_20 AC 116 ms
76,672 KB
testcase_21 AC 123 ms
76,800 KB
testcase_22 AC 129 ms
76,800 KB
testcase_23 AC 123 ms
76,672 KB
testcase_24 AC 125 ms
77,056 KB
testcase_25 AC 129 ms
77,056 KB
testcase_26 AC 126 ms
76,544 KB
testcase_27 AC 133 ms
76,928 KB
testcase_28 AC 126 ms
76,928 KB
testcase_29 AC 133 ms
77,312 KB
testcase_30 AC 133 ms
77,184 KB
testcase_31 AC 129 ms
77,184 KB
testcase_32 AC 131 ms
77,056 KB
testcase_33 AC 164 ms
78,720 KB
testcase_34 AC 155 ms
78,976 KB
testcase_35 AC 157 ms
79,232 KB
testcase_36 AC 151 ms
78,720 KB
testcase_37 AC 158 ms
78,720 KB
testcase_38 AC 58 ms
62,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))
mod = 998244353
from collections import defaultdict
dp = defaultdict(lambda: 0)
dp[0] = 1
for a in A:
    nx = defaultdict(lambda: 0)
    for k, v in dp.items():
        nx[k+a] += v
        nx[k+a] %= mod
        nx[k-a] += v
        nx[k-a] %= mod
    dp = nx
ans = 0
for k, v in dp.items():
    ans += abs(k)*v
    ans %= mod
print(ans)
0