結果

問題 No.1645 AB's abs
ユーザー 👑 rin204rin204
提出日時 2021-09-03 18:44:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 406 bytes
コンパイル時間 711 ms
コンパイル使用メモリ 87,288 KB
実行使用メモリ 81,356 KB
最終ジャッジ日時 2023-08-21 16:41:33
合計ジャッジ時間 8,170 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
71,656 KB
testcase_01 AC 90 ms
71,804 KB
testcase_02 AC 115 ms
77,944 KB
testcase_03 AC 86 ms
71,876 KB
testcase_04 AC 87 ms
71,820 KB
testcase_05 AC 86 ms
71,752 KB
testcase_06 AC 89 ms
71,712 KB
testcase_07 AC 87 ms
71,712 KB
testcase_08 AC 115 ms
77,812 KB
testcase_09 AC 116 ms
77,652 KB
testcase_10 AC 114 ms
77,740 KB
testcase_11 AC 116 ms
77,764 KB
testcase_12 AC 116 ms
77,996 KB
testcase_13 AC 153 ms
78,608 KB
testcase_14 AC 142 ms
78,152 KB
testcase_15 AC 154 ms
78,776 KB
testcase_16 AC 151 ms
78,500 KB
testcase_17 AC 151 ms
78,772 KB
testcase_18 AC 147 ms
78,332 KB
testcase_19 AC 150 ms
78,256 KB
testcase_20 AC 141 ms
78,440 KB
testcase_21 AC 150 ms
78,572 KB
testcase_22 AC 151 ms
78,308 KB
testcase_23 AC 150 ms
78,364 KB
testcase_24 AC 148 ms
78,564 KB
testcase_25 AC 154 ms
78,716 KB
testcase_26 AC 152 ms
78,596 KB
testcase_27 AC 157 ms
78,444 KB
testcase_28 AC 152 ms
78,540 KB
testcase_29 AC 155 ms
78,596 KB
testcase_30 AC 158 ms
78,624 KB
testcase_31 AC 153 ms
78,496 KB
testcase_32 AC 159 ms
78,696 KB
testcase_33 AC 181 ms
81,164 KB
testcase_34 AC 179 ms
81,152 KB
testcase_35 AC 178 ms
81,356 KB
testcase_36 AC 175 ms
81,096 KB
testcase_37 AC 180 ms
81,088 KB
testcase_38 AC 97 ms
77,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict as dd
MOD = 998244353

n = int(input())
alst = list(map(int, input().split()))
dp = dd(int)
dp[0] = 1

for a in alst:
    dp2 = dd(int)
    for k, v in dp.items():
        dp2[k - a] += v
        dp2[k + a] += v
        dp2[k - a] %= MOD
        dp2[k + a] %= MOD
    dp = dp2
            
ans = 0
for k, v in dp.items():
    ans += abs(k) * v
    ans %= MOD
print(ans)
0