結果

問題 No.1645 AB's abs
ユーザー lloyzlloyz
提出日時 2021-12-18 20:25:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 113 ms / 2,000 ms
コード長 475 bytes
コンパイル時間 2,133 ms
コンパイル使用メモリ 86,268 KB
実行使用メモリ 92,188 KB
最終ジャッジ日時 2023-10-13 18:03:29
合計ジャッジ時間 8,349 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
76,420 KB
testcase_01 AC 72 ms
76,240 KB
testcase_02 AC 87 ms
81,172 KB
testcase_03 AC 77 ms
76,372 KB
testcase_04 AC 78 ms
76,768 KB
testcase_05 AC 76 ms
76,900 KB
testcase_06 AC 79 ms
77,592 KB
testcase_07 AC 77 ms
76,748 KB
testcase_08 AC 89 ms
82,276 KB
testcase_09 AC 91 ms
82,388 KB
testcase_10 AC 90 ms
82,116 KB
testcase_11 AC 88 ms
81,920 KB
testcase_12 AC 89 ms
81,812 KB
testcase_13 AC 109 ms
91,600 KB
testcase_14 AC 106 ms
90,712 KB
testcase_15 AC 104 ms
91,680 KB
testcase_16 AC 103 ms
90,976 KB
testcase_17 AC 109 ms
91,620 KB
testcase_18 AC 111 ms
91,020 KB
testcase_19 AC 106 ms
91,540 KB
testcase_20 AC 105 ms
90,308 KB
testcase_21 AC 106 ms
90,864 KB
testcase_22 AC 107 ms
91,480 KB
testcase_23 AC 109 ms
91,916 KB
testcase_24 AC 108 ms
91,856 KB
testcase_25 AC 109 ms
92,076 KB
testcase_26 AC 107 ms
92,188 KB
testcase_27 AC 105 ms
91,908 KB
testcase_28 AC 106 ms
91,960 KB
testcase_29 AC 103 ms
91,920 KB
testcase_30 AC 106 ms
91,956 KB
testcase_31 AC 106 ms
91,804 KB
testcase_32 AC 108 ms
92,156 KB
testcase_33 AC 110 ms
91,972 KB
testcase_34 AC 109 ms
91,948 KB
testcase_35 AC 113 ms
91,844 KB
testcase_36 AC 112 ms
92,136 KB
testcase_37 AC 110 ms
91,932 KB
testcase_38 AC 102 ms
91,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

mod = 998244353
dp = [[0 for _ in range(20001)] for _ in range(n + 1)]
dp[0][10000] = 1
for i in range(n):
    for j in range(20001):
        if dp[i][j] != 0:
            dp[i + 1][j - A[i]] += dp[i][j]
            dp[i + 1][j - A[i]] %= mod
            dp[i + 1][j + A[i]] += dp[i][j]
            dp[i + 1][j + A[i]] %= mod

ans = 0
for j in range(20001):
    ans += abs(j - 10000) * dp[n][j]
    ans %= mod
print(ans)
0