結果

問題 No.1645 AB's abs
ユーザー rlangevinrlangevin
提出日時 2022-12-31 22:41:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 491 bytes
コンパイル時間 333 ms
コンパイル使用メモリ 87,264 KB
実行使用メモリ 82,740 KB
最終ジャッジ日時 2023-08-17 21:44:37
合計ジャッジ時間 7,430 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,272 KB
testcase_01 AC 79 ms
70,764 KB
testcase_02 AC 99 ms
76,492 KB
testcase_03 AC 80 ms
71,172 KB
testcase_04 AC 78 ms
71,096 KB
testcase_05 AC 86 ms
76,272 KB
testcase_06 AC 92 ms
76,196 KB
testcase_07 AC 84 ms
76,248 KB
testcase_08 AC 100 ms
76,296 KB
testcase_09 AC 105 ms
76,924 KB
testcase_10 AC 100 ms
76,412 KB
testcase_11 AC 100 ms
76,388 KB
testcase_12 AC 100 ms
76,300 KB
testcase_13 AC 136 ms
77,324 KB
testcase_14 AC 127 ms
76,972 KB
testcase_15 AC 139 ms
76,960 KB
testcase_16 AC 138 ms
77,200 KB
testcase_17 AC 137 ms
77,044 KB
testcase_18 AC 130 ms
77,288 KB
testcase_19 AC 135 ms
77,352 KB
testcase_20 AC 128 ms
77,364 KB
testcase_21 AC 132 ms
77,060 KB
testcase_22 AC 138 ms
77,336 KB
testcase_23 AC 135 ms
77,096 KB
testcase_24 AC 135 ms
77,216 KB
testcase_25 AC 138 ms
77,352 KB
testcase_26 AC 136 ms
77,068 KB
testcase_27 AC 140 ms
77,400 KB
testcase_28 AC 136 ms
77,252 KB
testcase_29 AC 138 ms
77,148 KB
testcase_30 AC 142 ms
77,372 KB
testcase_31 AC 135 ms
77,160 KB
testcase_32 AC 136 ms
77,376 KB
testcase_33 AC 173 ms
82,212 KB
testcase_34 AC 170 ms
82,204 KB
testcase_35 AC 176 ms
82,284 KB
testcase_36 AC 171 ms
82,356 KB
testcase_37 AC 170 ms
82,312 KB
testcase_38 AC 179 ms
82,740 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
mod = 998244353
geta = sum(A) + 5

pre = [0] * (geta * 2)
pre[geta] = 1
for i in range(N):
    dp = [0] * (geta * 2)
    for j in range(2 * geta):
        for k in range(-1, 2, 2):
            if 0 <= j + A[i] * k <= 2 * geta - 1:
                dp[j + A[i] * k] += pre[j]
                dp[j + A[i] * k] %= mod
    pre, dp = dp, pre
    
ans = 0
for i in range(2 * geta):
    ans += pre[i] * abs(geta - i)
    ans %= mod
print(ans)    
0