結果

問題 No.1645 AB's abs
ユーザー moharan627moharan627
提出日時 2021-08-13 22:08:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 648 ms / 2,000 ms
コード長 942 bytes
コンパイル時間 195 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 26,368 KB
最終ジャッジ日時 2024-04-14 18:09:47
合計ジャッジ時間 19,607 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
11,776 KB
testcase_01 AC 32 ms
11,776 KB
testcase_02 AC 214 ms
14,464 KB
testcase_03 AC 32 ms
11,648 KB
testcase_04 AC 39 ms
11,648 KB
testcase_05 AC 51 ms
11,904 KB
testcase_06 AC 74 ms
12,160 KB
testcase_07 AC 45 ms
11,776 KB
testcase_08 AC 263 ms
15,360 KB
testcase_09 AC 263 ms
15,360 KB
testcase_10 AC 239 ms
14,976 KB
testcase_11 AC 238 ms
14,848 KB
testcase_12 AC 246 ms
14,976 KB
testcase_13 AC 625 ms
23,936 KB
testcase_14 AC 587 ms
22,016 KB
testcase_15 AC 630 ms
23,808 KB
testcase_16 AC 595 ms
23,168 KB
testcase_17 AC 622 ms
23,552 KB
testcase_18 AC 599 ms
22,784 KB
testcase_19 AC 623 ms
23,680 KB
testcase_20 AC 576 ms
22,144 KB
testcase_21 AC 603 ms
22,784 KB
testcase_22 AC 622 ms
23,424 KB
testcase_23 AC 639 ms
23,552 KB
testcase_24 AC 637 ms
23,808 KB
testcase_25 AC 639 ms
24,192 KB
testcase_26 AC 638 ms
23,680 KB
testcase_27 AC 636 ms
23,936 KB
testcase_28 AC 639 ms
23,808 KB
testcase_29 AC 645 ms
23,808 KB
testcase_30 AC 637 ms
24,064 KB
testcase_31 AC 630 ms
24,192 KB
testcase_32 AC 637 ms
24,320 KB
testcase_33 AC 648 ms
26,112 KB
testcase_34 AC 642 ms
26,240 KB
testcase_35 AC 645 ms
26,368 KB
testcase_36 AC 647 ms
26,368 KB
testcase_37 AC 642 ms
26,240 KB
testcase_38 AC 628 ms
20,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
INF = float('inf')
#10**20,2**63,float('inf')
MOD = 10**9 + 7
MOD2 = 998244353
#from collections import defaultdict
def solve():
    def II(): return int(sys.stdin.readline())
    def LI(): return list(map(int, sys.stdin.readline().split()))
    def LC(): return list(input())
    def IC(): return [int(c) for c in input()]
    def MI(): return map(int, sys.stdin.readline().split())
    N = II()
    A = LI()
    DP = [[0]*11000 for _ in range(N+10)]
    DP[0][A[0]] = 2
    for a in range(1,N):
        for n in range(10010):
            DP[a][abs(n+A[a])] += DP[a-1][n]
            DP[a][abs(n+A[a])] %= MOD2
            DP[a][abs(n-A[a])] += DP[a-1][n]
            DP[a][abs(n-A[a])] %= MOD2
        #print(DP[a])
    Ans = 0
    for n in range(10010):
        Ans += n*DP[N-1][n]
        Ans %= MOD2
    print(Ans%MOD2)
    return
solve()
#sys.setrecursionlimit(10 ** 6)#再帰関数ではコメントにしないこと!!
0