結果

問題 No.1645 AB's abs
ユーザー puznekopuzneko
提出日時 2021-10-24 23:03:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 515 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 82,448 KB
実行使用メモリ 82,288 KB
最終ジャッジ日時 2024-04-10 04:02:12
合計ジャッジ時間 4,794 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,868 KB
testcase_01 AC 36 ms
53,292 KB
testcase_02 AC 59 ms
67,472 KB
testcase_03 AC 36 ms
53,328 KB
testcase_04 AC 36 ms
52,884 KB
testcase_05 AC 43 ms
61,004 KB
testcase_06 AC 49 ms
62,940 KB
testcase_07 AC 42 ms
60,564 KB
testcase_08 AC 61 ms
68,256 KB
testcase_09 AC 61 ms
68,028 KB
testcase_10 AC 63 ms
68,744 KB
testcase_11 AC 60 ms
68,164 KB
testcase_12 AC 60 ms
67,492 KB
testcase_13 AC 98 ms
81,392 KB
testcase_14 AC 94 ms
78,768 KB
testcase_15 AC 97 ms
81,816 KB
testcase_16 AC 97 ms
79,548 KB
testcase_17 AC 101 ms
80,376 KB
testcase_18 AC 96 ms
80,548 KB
testcase_19 AC 100 ms
80,624 KB
testcase_20 AC 93 ms
78,496 KB
testcase_21 AC 95 ms
79,432 KB
testcase_22 AC 99 ms
81,232 KB
testcase_23 AC 99 ms
81,792 KB
testcase_24 AC 101 ms
81,484 KB
testcase_25 AC 97 ms
80,812 KB
testcase_26 AC 98 ms
81,240 KB
testcase_27 AC 98 ms
82,288 KB
testcase_28 AC 100 ms
81,972 KB
testcase_29 AC 98 ms
81,344 KB
testcase_30 AC 100 ms
81,440 KB
testcase_31 AC 99 ms
82,164 KB
testcase_32 AC 99 ms
81,952 KB
testcase_33 AC 97 ms
81,760 KB
testcase_34 AC 98 ms
81,408 KB
testcase_35 AC 98 ms
81,024 KB
testcase_36 AC 98 ms
81,756 KB
testcase_37 AC 102 ms
81,736 KB
testcase_38 AC 100 ms
81,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin
n, *a = map(int, stdin.read().split())
p = 998244353
largenum = n * max(a) + 1
maxind = largenum * 2
dp = [[0 for i in range(maxind + 1)] for j in range(n+1)]
dp[0][largenum] = 1

for i in range(n):
    for j in range(maxind + 1):
        if j >= a[i]:
            dp[i+1][j] = dp[i][j-a[i]]
        if j <= maxind - a[i]:
            dp[i+1][j] = (dp[i+1][j] + dp[i][j+a[i]]) % p

ans = 0
for i in range(maxind+1):
    ans = (ans + abs(i-largenum) * dp[n][i] % p) % p
print("{}".format(ans))
0