結果

問題 No.1645 AB's abs
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-08-13 21:48:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 422 bytes
コンパイル時間 443 ms
コンパイル使用メモリ 82,548 KB
実行使用メモリ 81,876 KB
最終ジャッジ日時 2024-04-14 17:32:08
合計ジャッジ時間 4,831 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
62,092 KB
testcase_01 AC 46 ms
60,896 KB
testcase_02 AC 65 ms
69,632 KB
testcase_03 AC 45 ms
61,600 KB
testcase_04 AC 48 ms
62,624 KB
testcase_05 AC 48 ms
62,096 KB
testcase_06 AC 51 ms
64,024 KB
testcase_07 AC 49 ms
62,276 KB
testcase_08 AC 66 ms
72,328 KB
testcase_09 AC 66 ms
71,092 KB
testcase_10 AC 65 ms
70,516 KB
testcase_11 AC 66 ms
70,252 KB
testcase_12 AC 65 ms
70,776 KB
testcase_13 AC 82 ms
80,784 KB
testcase_14 AC 80 ms
79,972 KB
testcase_15 AC 83 ms
81,092 KB
testcase_16 AC 81 ms
80,728 KB
testcase_17 AC 80 ms
79,824 KB
testcase_18 AC 82 ms
79,888 KB
testcase_19 AC 82 ms
81,480 KB
testcase_20 AC 85 ms
80,168 KB
testcase_21 AC 82 ms
80,528 KB
testcase_22 AC 81 ms
81,116 KB
testcase_23 AC 80 ms
80,616 KB
testcase_24 AC 81 ms
80,656 KB
testcase_25 AC 82 ms
81,524 KB
testcase_26 AC 83 ms
81,836 KB
testcase_27 AC 82 ms
81,816 KB
testcase_28 AC 87 ms
81,376 KB
testcase_29 AC 85 ms
81,052 KB
testcase_30 AC 83 ms
81,876 KB
testcase_31 AC 83 ms
80,680 KB
testcase_32 AC 83 ms
80,700 KB
testcase_33 AC 82 ms
81,528 KB
testcase_34 AC 87 ms
80,824 KB
testcase_35 AC 84 ms
80,056 KB
testcase_36 AC 82 ms
81,352 KB
testcase_37 AC 83 ms
80,736 KB
testcase_38 AC 76 ms
78,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

M = 2*10**4
dp = [0]*(M+5)
dp[0] = 1
for a in A:
    ndp = [0]*(M+5)
    for i in range(-10**4,10**4+1):
        if dp[i] == 0:
            continue
        ndp[i+a] += dp[i]
        ndp[i+a] %= mod
        ndp[i-a] += dp[i]
        ndp[i-a] %= mod
    dp = ndp

ans = 0
for i in range(-10**4,10**4+1):
    ans += abs(i)*dp[i] 
    ans %= mod
print(ans)
0