結果

問題 No.1645 AB's abs
ユーザー 👑 H20H20
提出日時 2021-08-13 22:15:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 340 bytes
コンパイル時間 219 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 78,284 KB
最終ジャッジ日時 2024-04-14 18:23:04
合計ジャッジ時間 6,019 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
53,760 KB
testcase_01 AC 47 ms
53,760 KB
testcase_02 AC 70 ms
68,224 KB
testcase_03 AC 46 ms
53,760 KB
testcase_04 AC 46 ms
53,760 KB
testcase_05 AC 46 ms
53,888 KB
testcase_06 AC 47 ms
53,760 KB
testcase_07 AC 47 ms
54,016 KB
testcase_08 AC 66 ms
68,096 KB
testcase_09 AC 68 ms
69,248 KB
testcase_10 AC 66 ms
67,584 KB
testcase_11 AC 69 ms
68,864 KB
testcase_12 AC 69 ms
68,352 KB
testcase_13 AC 134 ms
77,220 KB
testcase_14 AC 125 ms
77,312 KB
testcase_15 AC 133 ms
77,260 KB
testcase_16 AC 135 ms
77,176 KB
testcase_17 AC 131 ms
77,460 KB
testcase_18 AC 131 ms
77,352 KB
testcase_19 AC 134 ms
77,056 KB
testcase_20 AC 128 ms
77,440 KB
testcase_21 AC 129 ms
77,296 KB
testcase_22 AC 137 ms
77,376 KB
testcase_23 AC 140 ms
77,252 KB
testcase_24 AC 138 ms
77,328 KB
testcase_25 AC 137 ms
77,036 KB
testcase_26 AC 129 ms
76,928 KB
testcase_27 AC 131 ms
77,184 KB
testcase_28 AC 138 ms
77,312 KB
testcase_29 AC 136 ms
77,312 KB
testcase_30 AC 137 ms
77,184 KB
testcase_31 AC 136 ms
77,156 KB
testcase_32 AC 139 ms
77,096 KB
testcase_33 AC 158 ms
77,992 KB
testcase_34 AC 164 ms
78,236 KB
testcase_35 AC 165 ms
78,284 KB
testcase_36 AC 157 ms
78,232 KB
testcase_37 AC 165 ms
78,080 KB
testcase_38 AC 58 ms
63,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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