結果

問題 No.1645 AB's abs
ユーザー mkawa2mkawa2
提出日時 2021-08-13 21:39:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 136 ms / 2,000 ms
コード長 891 bytes
コンパイル時間 237 ms
コンパイル使用メモリ 82,208 KB
実行使用メモリ 91,460 KB
最終ジャッジ日時 2024-04-14 17:13:47
合計ジャッジ時間 5,660 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 50 ms
63,632 KB
testcase_01 AC 46 ms
61,676 KB
testcase_02 AC 65 ms
71,040 KB
testcase_03 AC 46 ms
61,792 KB
testcase_04 AC 50 ms
63,144 KB
testcase_05 AC 51 ms
63,724 KB
testcase_06 AC 57 ms
65,584 KB
testcase_07 AC 51 ms
63,844 KB
testcase_08 AC 68 ms
73,580 KB
testcase_09 AC 67 ms
72,192 KB
testcase_10 AC 67 ms
73,080 KB
testcase_11 AC 65 ms
71,732 KB
testcase_12 AC 66 ms
71,828 KB
testcase_13 AC 131 ms
90,768 KB
testcase_14 AC 124 ms
90,912 KB
testcase_15 AC 132 ms
90,736 KB
testcase_16 AC 124 ms
90,408 KB
testcase_17 AC 128 ms
90,736 KB
testcase_18 AC 126 ms
91,148 KB
testcase_19 AC 133 ms
90,852 KB
testcase_20 AC 119 ms
90,620 KB
testcase_21 AC 128 ms
91,460 KB
testcase_22 AC 131 ms
90,564 KB
testcase_23 AC 130 ms
90,944 KB
testcase_24 AC 132 ms
90,840 KB
testcase_25 AC 130 ms
90,952 KB
testcase_26 AC 131 ms
90,964 KB
testcase_27 AC 131 ms
90,892 KB
testcase_28 AC 131 ms
90,856 KB
testcase_29 AC 131 ms
90,756 KB
testcase_30 AC 132 ms
90,660 KB
testcase_31 AC 128 ms
90,716 KB
testcase_32 AC 131 ms
90,752 KB
testcase_33 AC 134 ms
90,520 KB
testcase_34 AC 136 ms
89,896 KB
testcase_35 AC 133 ms
90,372 KB
testcase_36 AC 136 ms
90,556 KB
testcase_37 AC 134 ms
90,680 KB
testcase_38 AC 126 ms
90,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def SI(): return sys.stdin.readline().rstrip()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
# inf = 10**16
md = 998244353
# md = 10**9+7

mx = 20005

n = II()
aa = LI()

dp = [0]*mx
dp[0] = 1

for a in aa:
    ndp = [0]*mx
    for i in range(-10000, 10001):
        ndp[i+a] += dp[i]
        ndp[i-a] += dp[i]
    dp = ndp

ans = 0
for i in range(-10000, 10001):
    ans += abs(i*dp[i])
    ans %= md

print(ans)
0