結果

問題 No.1645 AB's abs
ユーザー hir355hir355
提出日時 2021-08-13 21:30:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 495 bytes
コンパイル時間 527 ms
コンパイル使用メモリ 82,640 KB
実行使用メモリ 72,748 KB
最終ジャッジ日時 2024-04-14 16:47:13
合計ジャッジ時間 3,678 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,988 KB
testcase_01 AC 36 ms
53,140 KB
testcase_02 AC 49 ms
64,656 KB
testcase_03 AC 36 ms
52,868 KB
testcase_04 AC 36 ms
52,132 KB
testcase_05 AC 40 ms
59,452 KB
testcase_06 AC 42 ms
61,568 KB
testcase_07 AC 37 ms
53,792 KB
testcase_08 AC 49 ms
64,028 KB
testcase_09 AC 50 ms
64,320 KB
testcase_10 AC 52 ms
64,500 KB
testcase_11 AC 50 ms
63,896 KB
testcase_12 AC 51 ms
64,680 KB
testcase_13 AC 68 ms
71,156 KB
testcase_14 AC 66 ms
70,096 KB
testcase_15 AC 68 ms
72,564 KB
testcase_16 AC 66 ms
71,536 KB
testcase_17 AC 66 ms
72,072 KB
testcase_18 AC 66 ms
70,744 KB
testcase_19 AC 66 ms
71,136 KB
testcase_20 AC 64 ms
69,976 KB
testcase_21 AC 66 ms
71,668 KB
testcase_22 AC 68 ms
71,684 KB
testcase_23 AC 66 ms
71,444 KB
testcase_24 AC 67 ms
72,736 KB
testcase_25 AC 67 ms
71,608 KB
testcase_26 AC 68 ms
71,500 KB
testcase_27 AC 68 ms
71,196 KB
testcase_28 AC 68 ms
71,536 KB
testcase_29 AC 68 ms
72,432 KB
testcase_30 AC 67 ms
71,280 KB
testcase_31 AC 67 ms
71,440 KB
testcase_32 AC 67 ms
72,128 KB
testcase_33 AC 68 ms
72,352 KB
testcase_34 AC 68 ms
71,392 KB
testcase_35 AC 68 ms
72,536 KB
testcase_36 AC 67 ms
72,748 KB
testcase_37 AC 67 ms
71,560 KB
testcase_38 AC 67 ms
72,620 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353
MAX = 100
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
dp = [[0] * (MAX * n + 1) for _ in range(n + 1)]
dp[0][0] = 1
for i in range(n):
    for j in range(MAX * n + 1):
        if j >= a[i]:
            dp[i + 1][j] += dp[i][j - a[i]]
        dp[i + 1][j] += dp[i][j]
        dp[i + 1][j] %= MOD
ans = 0
for i in range(MAX * n + 1):
    if 2 * i - s >= 0:
        ans += (2 * i - s) * dp[-1][i]
    else:
        ans -= (2 * i - s) * dp[-1][i]
print(ans % MOD)
0