結果

問題 No.1645 AB's abs
ユーザー ntudantuda
提出日時 2021-08-15 01:08:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 171 ms / 2,000 ms
コード長 488 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 82,032 KB
実行使用メモリ 79,736 KB
最終ジャッジ日時 2024-04-15 22:59:04
合計ジャッジ時間 5,900 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
51,712 KB
testcase_01 AC 41 ms
52,096 KB
testcase_02 AC 61 ms
65,920 KB
testcase_03 AC 41 ms
52,224 KB
testcase_04 AC 41 ms
51,840 KB
testcase_05 AC 41 ms
52,096 KB
testcase_06 AC 42 ms
52,480 KB
testcase_07 AC 41 ms
51,968 KB
testcase_08 AC 62 ms
68,224 KB
testcase_09 AC 62 ms
69,120 KB
testcase_10 AC 61 ms
67,200 KB
testcase_11 AC 61 ms
67,840 KB
testcase_12 AC 62 ms
68,352 KB
testcase_13 AC 142 ms
77,184 KB
testcase_14 AC 131 ms
76,928 KB
testcase_15 AC 147 ms
77,568 KB
testcase_16 AC 141 ms
77,392 KB
testcase_17 AC 140 ms
77,188 KB
testcase_18 AC 135 ms
77,308 KB
testcase_19 AC 138 ms
77,056 KB
testcase_20 AC 130 ms
76,544 KB
testcase_21 AC 136 ms
76,800 KB
testcase_22 AC 141 ms
77,312 KB
testcase_23 AC 141 ms
77,184 KB
testcase_24 AC 139 ms
77,440 KB
testcase_25 AC 143 ms
77,248 KB
testcase_26 AC 142 ms
77,552 KB
testcase_27 AC 145 ms
77,412 KB
testcase_28 AC 143 ms
77,048 KB
testcase_29 AC 143 ms
77,228 KB
testcase_30 AC 147 ms
77,312 KB
testcase_31 AC 143 ms
77,452 KB
testcase_32 AC 148 ms
77,696 KB
testcase_33 AC 171 ms
79,736 KB
testcase_34 AC 170 ms
78,848 KB
testcase_35 AC 163 ms
79,224 KB
testcase_36 AC 167 ms
79,488 KB
testcase_37 AC 167 ms
79,104 KB
testcase_38 AC 57 ms
62,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))

mod = 998244353
dic1 = {A[0]:1,-A[0]:1}
dic2 = {}
for i in range(1,N):
    for k,v in dic1.items():
        t = A[i] + k
        if t in dic2:
            dic2[t] += v
        else:
            dic2[t] = v
        t = - A[i] + k
        if t in dic2:
            dic2[t] += v
        else:
            dic2[t] = v
    dic1,dic2 = dic2,dic1
    dic2.clear()
ans = 0
for k,v in dic1.items():
    ans = (ans + v * abs(k)) % mod
print(ans)
0