結果

問題 No.1645 AB's abs
ユーザー U S
提出日時 2021-08-13 23:21:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 729 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 107,172 KB
最終ジャッジ日時 2024-10-03 23:14:02
合計ジャッジ時間 7,153 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

# import sys
# #sys.setrecursionlimit(1000000)
# input = sys.stdin.readline
def mp():return map(int,input().split())
def lmp():return list(map(int,input().split()))
import math
import bisect
from copy import deepcopy as dc
from itertools import accumulate
from collections import Counter, defaultdict, deque
import itertools
def ceil(U,V):return (U+V-1)//V
def modf1(N,MOD):return (N-1)%MOD+1
inf = int(1e30)
mod = 998244353

n = int(input())
a = lmp()
dp = [[0]*21000 for i in range(n)]
dp[0][a[0]] = 1
dp[0][-a[0]] = 1
for i in range(n-1):
    for j in range(-10000,10001, 1):
        dp[i+1][j+a[i+1]] += dp[i][j]
        dp[i+1][j-a[i+1]] += dp[i][j]
ans = 0
for i in range(10001):
    ans += i*dp[-1][i]
print(ans*2 % mod)

0