結果

問題 No.1645 AB's abs
ユーザー lloyzlloyz
提出日時 2021-12-18 20:26:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 826 ms / 2,000 ms
コード長 494 bytes
コンパイル時間 640 ms
コンパイル使用メモリ 10,864 KB
実行使用メモリ 36,604 KB
最終ジャッジ日時 2023-10-13 18:03:54
合計ジャッジ時間 20,469 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
8,736 KB
testcase_01 AC 27 ms
8,660 KB
testcase_02 AC 140 ms
13,464 KB
testcase_03 AC 27 ms
8,644 KB
testcase_04 AC 31 ms
8,632 KB
testcase_05 AC 38 ms
8,948 KB
testcase_06 AC 50 ms
9,572 KB
testcase_07 AC 35 ms
8,984 KB
testcase_08 AC 182 ms
15,100 KB
testcase_09 AC 191 ms
15,336 KB
testcase_10 AC 165 ms
14,484 KB
testcase_11 AC 174 ms
14,604 KB
testcase_12 AC 172 ms
14,776 KB
testcase_13 AC 615 ms
31,188 KB
testcase_14 AC 519 ms
28,128 KB
testcase_15 AC 634 ms
31,528 KB
testcase_16 AC 585 ms
30,332 KB
testcase_17 AC 620 ms
31,092 KB
testcase_18 AC 545 ms
29,260 KB
testcase_19 AC 597 ms
31,052 KB
testcase_20 AC 509 ms
27,948 KB
testcase_21 AC 558 ms
29,504 KB
testcase_22 AC 615 ms
31,136 KB
testcase_23 AC 602 ms
30,944 KB
testcase_24 AC 621 ms
31,856 KB
testcase_25 AC 636 ms
31,968 KB
testcase_26 AC 602 ms
31,420 KB
testcase_27 AC 640 ms
31,668 KB
testcase_28 AC 635 ms
31,584 KB
testcase_29 AC 623 ms
31,588 KB
testcase_30 AC 641 ms
32,236 KB
testcase_31 AC 627 ms
31,992 KB
testcase_32 AC 628 ms
32,328 KB
testcase_33 AC 796 ms
36,284 KB
testcase_34 AC 796 ms
36,604 KB
testcase_35 AC 826 ms
36,544 KB
testcase_36 AC 807 ms
36,456 KB
testcase_37 AC 806 ms
36,472 KB
testcase_38 AC 351 ms
24,488 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