結果

問題 No.1645 AB's abs
ユーザー ntudantuda
提出日時 2021-08-15 01:19:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 123 ms / 2,000 ms
コード長 507 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 78,336 KB
最終ジャッジ日時 2024-04-15 23:10:31
合計ジャッジ時間 4,784 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
51,840 KB
testcase_01 AC 40 ms
51,712 KB
testcase_02 AC 61 ms
65,792 KB
testcase_03 AC 40 ms
51,584 KB
testcase_04 AC 41 ms
51,840 KB
testcase_05 AC 41 ms
51,712 KB
testcase_06 AC 41 ms
51,840 KB
testcase_07 AC 44 ms
51,712 KB
testcase_08 AC 65 ms
68,480 KB
testcase_09 AC 67 ms
69,504 KB
testcase_10 AC 63 ms
67,072 KB
testcase_11 AC 67 ms
68,352 KB
testcase_12 AC 66 ms
68,096 KB
testcase_13 AC 103 ms
75,648 KB
testcase_14 AC 95 ms
75,520 KB
testcase_15 AC 103 ms
75,648 KB
testcase_16 AC 100 ms
76,032 KB
testcase_17 AC 97 ms
75,648 KB
testcase_18 AC 94 ms
75,776 KB
testcase_19 AC 97 ms
75,776 KB
testcase_20 AC 92 ms
75,776 KB
testcase_21 AC 98 ms
75,776 KB
testcase_22 AC 101 ms
75,776 KB
testcase_23 AC 98 ms
76,032 KB
testcase_24 AC 99 ms
75,776 KB
testcase_25 AC 100 ms
75,776 KB
testcase_26 AC 97 ms
75,776 KB
testcase_27 AC 103 ms
76,032 KB
testcase_28 AC 99 ms
76,032 KB
testcase_29 AC 104 ms
75,904 KB
testcase_30 AC 105 ms
75,648 KB
testcase_31 AC 99 ms
75,776 KB
testcase_32 AC 102 ms
76,032 KB
testcase_33 AC 123 ms
78,208 KB
testcase_34 AC 118 ms
77,952 KB
testcase_35 AC 119 ms
78,208 KB
testcase_36 AC 117 ms
78,336 KB
testcase_37 AC 118 ms
78,336 KB
testcase_38 AC 48 ms
59,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

mod = 998244353
dic1 = {0:1}
dic2 = {}
for i in range(N):
    for k,v in dic1.items():
        t = k + A[i]
        if t in dic2:
            dic2[t] = (dic2[t] + v) % mod
        else:
            dic2[t] = v
        t = k - A[i]
        if t in dic2:
            dic2[t] = (dic2[t] + v) % mod
        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