結果

問題 No.1645 AB's abs
ユーザー kept1994kept1994
提出日時 2022-05-06 02:48:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 590 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 87,060 KB
実行使用メモリ 103,260 KB
最終ジャッジ日時 2023-09-18 13:59:17
合計ジャッジ時間 6,925 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
76,196 KB
testcase_01 AC 84 ms
76,212 KB
testcase_02 AC 91 ms
80,700 KB
testcase_03 AC 86 ms
76,308 KB
testcase_04 AC 82 ms
76,196 KB
testcase_05 AC 86 ms
76,504 KB
testcase_06 AC 87 ms
77,228 KB
testcase_07 AC 85 ms
76,400 KB
testcase_08 AC 91 ms
82,212 KB
testcase_09 AC 94 ms
82,384 KB
testcase_10 AC 90 ms
81,556 KB
testcase_11 AC 90 ms
81,620 KB
testcase_12 AC 90 ms
81,708 KB
testcase_13 AC 153 ms
102,736 KB
testcase_14 AC 141 ms
98,276 KB
testcase_15 AC 153 ms
102,324 KB
testcase_16 AC 149 ms
100,684 KB
testcase_17 AC 152 ms
102,428 KB
testcase_18 AC 146 ms
99,740 KB
testcase_19 AC 153 ms
102,804 KB
testcase_20 AC 144 ms
97,524 KB
testcase_21 AC 148 ms
100,304 KB
testcase_22 AC 155 ms
102,492 KB
testcase_23 AC 155 ms
103,256 KB
testcase_24 AC 156 ms
103,172 KB
testcase_25 AC 159 ms
102,992 KB
testcase_26 AC 156 ms
103,220 KB
testcase_27 AC 156 ms
102,988 KB
testcase_28 AC 155 ms
103,204 KB
testcase_29 AC 155 ms
103,260 KB
testcase_30 AC 156 ms
103,064 KB
testcase_31 AC 155 ms
102,836 KB
testcase_32 AC 156 ms
102,908 KB
testcase_33 AC 158 ms
101,744 KB
testcase_34 AC 164 ms
101,768 KB
testcase_35 AC 157 ms
101,572 KB
testcase_36 AC 156 ms
101,644 KB
testcase_37 AC 159 ms
101,712 KB
testcase_38 AC 132 ms
97,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
import sys
MOD = 998244353
def main():
    N = int(input())
    A = list(map(int, input().split()))
    dp = [[0 for _ in range(20010)] for _ in range(N + 1)]
    offset = 10000
    dp[0][offset] = 1
    for i in range(N):
        for j in range(20010):
            if not dp[i][j]:
                continue
            dp[i + 1][j + A[i]] += dp[i][j]
            dp[i + 1][j - A[i]] += dp[i][j]
    ans = 0
    for j in range(20010):
        ans += abs(j - offset) * dp[-1][j]
        ans %= MOD
    print(ans % MOD)
    return

if __name__ == '__main__':
    main()
0