結果

問題 No.1645 AB's abs
ユーザー titiatitia
提出日時 2021-08-13 21:33:15
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 383 ms / 2,000 ms
コード長 405 bytes
コンパイル時間 576 ms
コンパイル使用メモリ 10,564 KB
実行使用メモリ 10,112 KB
最終ジャッジ日時 2023-07-27 03:29:30
合計ジャッジ時間 8,185 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,784 KB
testcase_01 AC 15 ms
7,708 KB
testcase_02 AC 33 ms
8,504 KB
testcase_03 AC 16 ms
7,908 KB
testcase_04 AC 15 ms
7,792 KB
testcase_05 AC 16 ms
7,888 KB
testcase_06 AC 16 ms
7,856 KB
testcase_07 AC 16 ms
7,816 KB
testcase_08 AC 43 ms
8,576 KB
testcase_09 AC 48 ms
8,496 KB
testcase_10 AC 38 ms
8,500 KB
testcase_11 AC 43 ms
8,500 KB
testcase_12 AC 42 ms
8,568 KB
testcase_13 AC 222 ms
9,012 KB
testcase_14 AC 163 ms
9,052 KB
testcase_15 AC 227 ms
9,292 KB
testcase_16 AC 220 ms
9,296 KB
testcase_17 AC 216 ms
9,416 KB
testcase_18 AC 186 ms
9,080 KB
testcase_19 AC 216 ms
9,028 KB
testcase_20 AC 169 ms
9,020 KB
testcase_21 AC 193 ms
9,096 KB
testcase_22 AC 219 ms
9,280 KB
testcase_23 AC 217 ms
9,036 KB
testcase_24 AC 220 ms
9,096 KB
testcase_25 AC 233 ms
9,280 KB
testcase_26 AC 219 ms
9,112 KB
testcase_27 AC 225 ms
9,396 KB
testcase_28 AC 217 ms
9,024 KB
testcase_29 AC 228 ms
9,104 KB
testcase_30 AC 247 ms
9,600 KB
testcase_31 AC 244 ms
9,032 KB
testcase_32 AC 240 ms
9,404 KB
testcase_33 AC 367 ms
10,112 KB
testcase_34 AC 372 ms
10,060 KB
testcase_35 AC 379 ms
9,992 KB
testcase_36 AC 373 ms
9,992 KB
testcase_37 AC 383 ms
9,988 KB
testcase_38 AC 21 ms
7,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

mod=998244353

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

D={0:1}

for a in A:
    ND=dict()

    for d in D:
        if d+a in ND:
            ND[d+a]+=D[d]
        else:
            ND[d+a]=D[d]

        if d-a in ND:
            ND[d-a]+=D[d]
        else:
            ND[d-a]=D[d]

    D=ND
    
ANS=0
for d in D:
    ANS=(ANS+abs(d)*D[d])%mod

print(ANS)
0