結果

問題 No.1645 AB's abs
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-08-13 21:34:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 135 ms / 2,000 ms
コード長 423 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 82,396 KB
実行使用メモリ 96,576 KB
最終ジャッジ日時 2024-04-14 16:57:35
合計ジャッジ時間 5,899 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
68,120 KB
testcase_01 AC 53 ms
62,916 KB
testcase_02 AC 91 ms
78,808 KB
testcase_03 AC 50 ms
63,920 KB
testcase_04 AC 62 ms
67,228 KB
testcase_05 AC 60 ms
68,620 KB
testcase_06 AC 67 ms
72,092 KB
testcase_07 AC 62 ms
68,720 KB
testcase_08 AC 92 ms
80,636 KB
testcase_09 AC 92 ms
81,908 KB
testcase_10 AC 91 ms
80,592 KB
testcase_11 AC 91 ms
80,248 KB
testcase_12 AC 91 ms
81,580 KB
testcase_13 AC 132 ms
95,504 KB
testcase_14 AC 127 ms
93,892 KB
testcase_15 AC 131 ms
95,128 KB
testcase_16 AC 126 ms
94,832 KB
testcase_17 AC 128 ms
95,624 KB
testcase_18 AC 126 ms
94,040 KB
testcase_19 AC 133 ms
95,116 KB
testcase_20 AC 125 ms
93,800 KB
testcase_21 AC 129 ms
94,156 KB
testcase_22 AC 130 ms
94,540 KB
testcase_23 AC 135 ms
96,316 KB
testcase_24 AC 132 ms
95,604 KB
testcase_25 AC 135 ms
95,276 KB
testcase_26 AC 134 ms
95,624 KB
testcase_27 AC 134 ms
96,576 KB
testcase_28 AC 132 ms
95,584 KB
testcase_29 AC 135 ms
95,496 KB
testcase_30 AC 133 ms
95,744 KB
testcase_31 AC 133 ms
95,840 KB
testcase_32 AC 133 ms
95,444 KB
testcase_33 AC 131 ms
95,336 KB
testcase_34 AC 131 ms
95,188 KB
testcase_35 AC 133 ms
95,168 KB
testcase_36 AC 133 ms
96,436 KB
testcase_37 AC 133 ms
95,396 KB
testcase_38 AC 129 ms
94,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

N = int(input())
A = list(map(int,input().split()))
mod = 998244353

dp = [[0] * 30000 for i in range(N+1)]
dp[0][0] = 1

for i in range(N):
    for j in range(10000,-10001,-1):
        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(10000,-10001,-1):

    ans += abs(dp[-1][j] * j)

print (ans % mod)
0