結果

問題 No.1645 AB's abs
ユーザー SidewaysOwlSidewaysOwl
提出日時 2021-08-13 23:21:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 519 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 82,684 KB
実行使用メモリ 93,776 KB
最終ジャッジ日時 2024-04-14 20:36:15
合計ジャッジ時間 4,114 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,740 KB
testcase_01 AC 36 ms
52,828 KB
testcase_02 AC 49 ms
63,716 KB
testcase_03 AC 36 ms
52,908 KB
testcase_04 AC 37 ms
53,156 KB
testcase_05 AC 42 ms
60,496 KB
testcase_06 AC 42 ms
59,520 KB
testcase_07 AC 42 ms
61,132 KB
testcase_08 AC 51 ms
65,040 KB
testcase_09 AC 51 ms
64,024 KB
testcase_10 AC 51 ms
63,408 KB
testcase_11 AC 50 ms
64,712 KB
testcase_12 AC 51 ms
64,648 KB
testcase_13 AC 73 ms
75,420 KB
testcase_14 AC 64 ms
72,680 KB
testcase_15 AC 75 ms
75,944 KB
testcase_16 AC 73 ms
75,964 KB
testcase_17 AC 75 ms
75,664 KB
testcase_18 AC 71 ms
75,556 KB
testcase_19 AC 73 ms
75,464 KB
testcase_20 AC 64 ms
73,784 KB
testcase_21 AC 71 ms
75,876 KB
testcase_22 AC 74 ms
75,600 KB
testcase_23 AC 73 ms
75,608 KB
testcase_24 AC 72 ms
75,288 KB
testcase_25 AC 74 ms
75,488 KB
testcase_26 AC 72 ms
75,420 KB
testcase_27 AC 74 ms
75,480 KB
testcase_28 AC 74 ms
75,428 KB
testcase_29 AC 73 ms
75,548 KB
testcase_30 AC 75 ms
75,680 KB
testcase_31 AC 74 ms
75,816 KB
testcase_32 AC 74 ms
75,908 KB
testcase_33 AC 103 ms
90,800 KB
testcase_34 AC 102 ms
91,272 KB
testcase_35 AC 101 ms
90,240 KB
testcase_36 AC 101 ms
90,040 KB
testcase_37 AC 101 ms
90,272 KB
testcase_38 AC 108 ms
93,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int,input().split()))
dp = [0] * (2 * sum(a) + 1)
dp[0] = 1
lendp = (2 * sum(a) + 1)
mod = 998244353
for i in range(n):
    n_dp = [0] * (lendp)
#     print(dp)
    for j in range(lendp ):
        if dp[j] >= 0:
            n_dp[(j+a[i]) % lendp] = (n_dp[(j+a[i]) % lendp] + dp[j]) % mod 
            n_dp[(j-a[i]) % lendp] = (n_dp[(j-a[i]) % lendp] + dp[j]) % mod
    dp = n_dp[::]
ans = 0
for i in range(sum(a)):
    ans = (ans + (i+1) * dp[(i+1)] + (i+1) * dp[-(i+1)] ) % mod
print(ans)
0