結果

問題 No.1645 AB's abs
ユーザー sgswsgsw
提出日時 2021-08-13 22:00:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 1,038 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 82,444 KB
実行使用メモリ 85,564 KB
最終ジャッジ日時 2024-04-14 17:50:22
合計ジャッジ時間 5,051 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
61,792 KB
testcase_01 AC 48 ms
62,300 KB
testcase_02 AC 79 ms
71,144 KB
testcase_03 AC 49 ms
62,084 KB
testcase_04 AC 50 ms
62,328 KB
testcase_05 AC 51 ms
63,060 KB
testcase_06 AC 57 ms
65,404 KB
testcase_07 AC 53 ms
63,468 KB
testcase_08 AC 76 ms
71,680 KB
testcase_09 AC 78 ms
72,180 KB
testcase_10 AC 74 ms
71,312 KB
testcase_11 AC 74 ms
72,628 KB
testcase_12 AC 73 ms
71,132 KB
testcase_13 AC 108 ms
84,164 KB
testcase_14 AC 103 ms
82,928 KB
testcase_15 AC 105 ms
84,116 KB
testcase_16 AC 101 ms
82,812 KB
testcase_17 AC 105 ms
83,656 KB
testcase_18 AC 105 ms
82,804 KB
testcase_19 AC 106 ms
83,760 KB
testcase_20 AC 100 ms
82,268 KB
testcase_21 AC 103 ms
82,792 KB
testcase_22 AC 107 ms
83,636 KB
testcase_23 AC 107 ms
84,500 KB
testcase_24 AC 106 ms
85,016 KB
testcase_25 AC 106 ms
83,368 KB
testcase_26 AC 107 ms
85,140 KB
testcase_27 AC 106 ms
83,508 KB
testcase_28 AC 106 ms
84,328 KB
testcase_29 AC 106 ms
84,140 KB
testcase_30 AC 109 ms
83,264 KB
testcase_31 AC 107 ms
84,564 KB
testcase_32 AC 108 ms
83,368 KB
testcase_33 AC 106 ms
83,524 KB
testcase_34 AC 116 ms
84,536 KB
testcase_35 AC 106 ms
84,256 KB
testcase_36 AC 107 ms
85,564 KB
testcase_37 AC 106 ms
83,584 KB
testcase_38 AC 107 ms
83,520 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

'''
    Python3(PyPy3) Template for Programming-Contest.

    author : sgsw

    generated : 2021/08/13   
    when : 21:56:07

'''

import sys


def input():
    return sys.stdin.readline().rstrip()


DXY = [(0, -1), (1, 0), (0, 1), (-1, 0)]  # LDRU
mod = 998244353
inf = 1 << 64


def main():
    n = int(input())
    a = list(map(int,input().split()))
    base = 12000
    dp = [[0]*(2 * base) for i in range(n + 1)]
    dp[0][0 + base] = 1
    for i in range(n):
        for val in range(-base,base):
            pre = dp[i][val + base]
            try:
                dp[i + 1][val - a[i]+ base] += pre
                dp[i + 1][val - a[i] + base] % mod 
            except:
                pass
            try:
                dp[i + 1][val + a[i] + base] += pre 
                dp[i + 1][val + a[i] + base] %= mod 
            except:
                pass
    ans = 0
    for i in range(-base,base):
        ans += abs(i) * dp[n][i + base]
        ans %= mod 
    print(ans)
    return 0


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