結果

問題 No.1645 AB's abs
ユーザー roarisroaris
提出日時 2021-08-20 19:50:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 154 ms / 2,000 ms
コード長 393 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 82,252 KB
実行使用メモリ 78,996 KB
最終ジャッジ日時 2024-04-22 02:09:22
合計ジャッジ時間 5,274 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
53,376 KB
testcase_01 AC 41 ms
53,620 KB
testcase_02 AC 69 ms
70,912 KB
testcase_03 AC 40 ms
53,120 KB
testcase_04 AC 39 ms
53,248 KB
testcase_05 AC 43 ms
53,248 KB
testcase_06 AC 41 ms
53,888 KB
testcase_07 AC 39 ms
53,760 KB
testcase_08 AC 74 ms
73,728 KB
testcase_09 AC 79 ms
76,288 KB
testcase_10 AC 72 ms
72,192 KB
testcase_11 AC 76 ms
74,112 KB
testcase_12 AC 72 ms
73,344 KB
testcase_13 AC 120 ms
77,056 KB
testcase_14 AC 104 ms
76,288 KB
testcase_15 AC 119 ms
77,056 KB
testcase_16 AC 115 ms
76,672 KB
testcase_17 AC 109 ms
76,544 KB
testcase_18 AC 110 ms
76,416 KB
testcase_19 AC 111 ms
76,288 KB
testcase_20 AC 105 ms
76,288 KB
testcase_21 AC 118 ms
76,568 KB
testcase_22 AC 125 ms
76,444 KB
testcase_23 AC 118 ms
76,420 KB
testcase_24 AC 123 ms
76,404 KB
testcase_25 AC 123 ms
76,800 KB
testcase_26 AC 118 ms
76,500 KB
testcase_27 AC 121 ms
76,928 KB
testcase_28 AC 120 ms
76,696 KB
testcase_29 AC 119 ms
76,800 KB
testcase_30 AC 125 ms
77,056 KB
testcase_31 AC 120 ms
76,928 KB
testcase_32 AC 121 ms
77,184 KB
testcase_33 AC 154 ms
78,764 KB
testcase_34 AC 141 ms
78,416 KB
testcase_35 AC 145 ms
78,996 KB
testcase_36 AC 140 ms
78,464 KB
testcase_37 AC 145 ms
78,848 KB
testcase_38 AC 55 ms
62,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *

N = int(input())
A = list(map(int, input().split()))
dp = defaultdict(int)
dp[0] = 1
MOD = 998244353

for Ai in A:
    ndp = defaultdict(int)
    
    for k in dp:
        ndp[k+Ai] += dp[k]
        ndp[k+Ai] %= MOD
        ndp[k-Ai] += dp[k]
        ndp[k-Ai] %= MOD

    dp = ndp

ans = 0

for k, v in dp.items():
    ans += abs(k)*v%MOD
    ans %= MOD

print(ans)
0