結果

問題 No.1645 AB's abs
ユーザー KeroruKeroru
提出日時 2021-08-13 22:54:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 333 bytes
コンパイル時間 205 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 97,560 KB
最終ジャッジ日時 2024-04-14 19:43:57
合計ジャッジ時間 4,656 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,472 KB
testcase_01 AC 36 ms
52,400 KB
testcase_02 AC 71 ms
73,452 KB
testcase_03 AC 37 ms
52,616 KB
testcase_04 AC 37 ms
52,884 KB
testcase_05 AC 43 ms
59,940 KB
testcase_06 AC 52 ms
64,392 KB
testcase_07 AC 42 ms
59,444 KB
testcase_08 AC 73 ms
74,292 KB
testcase_09 AC 71 ms
74,396 KB
testcase_10 AC 71 ms
73,724 KB
testcase_11 AC 71 ms
74,120 KB
testcase_12 AC 72 ms
73,960 KB
testcase_13 AC 89 ms
76,168 KB
testcase_14 AC 84 ms
76,204 KB
testcase_15 AC 90 ms
76,112 KB
testcase_16 AC 89 ms
76,328 KB
testcase_17 AC 91 ms
76,084 KB
testcase_18 AC 88 ms
76,104 KB
testcase_19 AC 90 ms
76,408 KB
testcase_20 AC 85 ms
76,192 KB
testcase_21 AC 85 ms
76,204 KB
testcase_22 AC 90 ms
76,148 KB
testcase_23 AC 88 ms
76,592 KB
testcase_24 AC 90 ms
76,344 KB
testcase_25 AC 89 ms
76,220 KB
testcase_26 AC 89 ms
76,128 KB
testcase_27 AC 90 ms
76,200 KB
testcase_28 AC 89 ms
76,172 KB
testcase_29 AC 88 ms
76,544 KB
testcase_30 AC 91 ms
76,228 KB
testcase_31 AC 89 ms
76,172 KB
testcase_32 AC 90 ms
76,096 KB
testcase_33 AC 114 ms
95,800 KB
testcase_34 AC 121 ms
96,248 KB
testcase_35 AC 114 ms
95,820 KB
testcase_36 AC 115 ms
95,836 KB
testcase_37 AC 112 ms
95,940 KB
testcase_38 AC 119 ms
97,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mo=998244353
n,*a=map(int,open(0).read().split())
N=sum(a)+1
d=[0]*N*2
d[0]=1
for x in a:
    nx=[0]*N*2
    for i in range(-N,N+1):
        if -N<=i-x<=N:nx[i-x]+=d[i]
        if -N<=i+x<=N:nx[i+x]+=d[i]
        nx[i-x]%=mo
        nx[i+x]%=mo
    d=nx[:]

ans=0
for i in range(-N,N+1):
    ans+=d[i]*abs(i)
    ans%=mo

print(ans)
0