結果

問題 No.1645 AB's abs
ユーザー moharan627moharan627
提出日時 2021-08-13 22:08:34
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 551 ms / 2,000 ms
コード長 942 bytes
コンパイル時間 656 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 23,736 KB
最終ジャッジ日時 2023-07-27 04:45:55
合計ジャッジ時間 17,624 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
9,180 KB
testcase_01 AC 19 ms
9,208 KB
testcase_02 AC 169 ms
11,724 KB
testcase_03 AC 18 ms
9,140 KB
testcase_04 AC 24 ms
9,176 KB
testcase_05 AC 35 ms
9,372 KB
testcase_06 AC 55 ms
9,864 KB
testcase_07 AC 28 ms
9,280 KB
testcase_08 AC 219 ms
12,888 KB
testcase_09 AC 219 ms
12,980 KB
testcase_10 AC 198 ms
12,256 KB
testcase_11 AC 199 ms
12,560 KB
testcase_12 AC 204 ms
12,608 KB
testcase_13 AC 532 ms
21,284 KB
testcase_14 AC 502 ms
19,520 KB
testcase_15 AC 533 ms
21,260 KB
testcase_16 AC 514 ms
20,656 KB
testcase_17 AC 532 ms
21,040 KB
testcase_18 AC 508 ms
20,132 KB
testcase_19 AC 537 ms
20,992 KB
testcase_20 AC 494 ms
19,568 KB
testcase_21 AC 509 ms
20,284 KB
testcase_22 AC 532 ms
20,980 KB
testcase_23 AC 540 ms
21,144 KB
testcase_24 AC 546 ms
21,432 KB
testcase_25 AC 541 ms
21,460 KB
testcase_26 AC 545 ms
21,248 KB
testcase_27 AC 544 ms
21,436 KB
testcase_28 AC 542 ms
21,252 KB
testcase_29 AC 548 ms
21,344 KB
testcase_30 AC 545 ms
21,640 KB
testcase_31 AC 544 ms
21,600 KB
testcase_32 AC 543 ms
21,756 KB
testcase_33 AC 549 ms
23,688 KB
testcase_34 AC 548 ms
23,700 KB
testcase_35 AC 546 ms
23,708 KB
testcase_36 AC 551 ms
23,736 KB
testcase_37 AC 549 ms
23,720 KB
testcase_38 AC 536 ms
17,696 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