結果

問題 No.1645 AB's abs
ユーザー wolgnikwolgnik
提出日時 2021-08-13 21:31:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 484 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 82,388 KB
実行使用メモリ 100,868 KB
最終ジャッジ日時 2024-04-14 16:49:52
合計ジャッジ時間 4,653 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,884 KB
testcase_01 AC 36 ms
53,820 KB
testcase_02 AC 61 ms
70,788 KB
testcase_03 AC 37 ms
52,812 KB
testcase_04 AC 38 ms
53,808 KB
testcase_05 AC 44 ms
61,872 KB
testcase_06 AC 55 ms
65,500 KB
testcase_07 AC 46 ms
62,256 KB
testcase_08 AC 64 ms
72,616 KB
testcase_09 AC 65 ms
73,084 KB
testcase_10 AC 62 ms
71,904 KB
testcase_11 AC 63 ms
72,900 KB
testcase_12 AC 63 ms
73,204 KB
testcase_13 AC 102 ms
97,432 KB
testcase_14 AC 95 ms
94,392 KB
testcase_15 AC 100 ms
98,220 KB
testcase_16 AC 98 ms
95,064 KB
testcase_17 AC 100 ms
97,044 KB
testcase_18 AC 98 ms
94,976 KB
testcase_19 AC 101 ms
97,608 KB
testcase_20 AC 95 ms
94,632 KB
testcase_21 AC 97 ms
94,640 KB
testcase_22 AC 100 ms
97,376 KB
testcase_23 AC 103 ms
98,980 KB
testcase_24 AC 103 ms
99,140 KB
testcase_25 AC 101 ms
99,440 KB
testcase_26 AC 101 ms
99,852 KB
testcase_27 AC 102 ms
99,724 KB
testcase_28 AC 103 ms
100,092 KB
testcase_29 AC 102 ms
99,188 KB
testcase_30 AC 104 ms
99,160 KB
testcase_31 AC 103 ms
99,648 KB
testcase_32 AC 104 ms
99,100 KB
testcase_33 AC 102 ms
99,516 KB
testcase_34 AC 108 ms
100,868 KB
testcase_35 AC 102 ms
98,736 KB
testcase_36 AC 100 ms
98,540 KB
testcase_37 AC 101 ms
98,844 KB
testcase_38 AC 97 ms
98,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
mod = 998244353

mx = max(a)
m = mx * N
ln = mx * N * 2 + 1
dp = [0] * ln
dp[m] = 1

for x in a:
  dp2 = [0] * ln
  for i in range(ln):
    if i - x in range(ln):
      dp2[i - x] += dp[i]
      dp2[i - x] %= mod
    if i + x in range(ln):
      dp2[i + x] += dp[i]
      dp2[i + x] %= mod
  dp = dp2[: ]

res = 0
for i in range(ln):
  x = i - m
  res += abs(x * dp[i])
  res %= mod
print(res)
0