結果

問題 No.1645 AB's abs
ユーザー taiga0629kyoprotaiga0629kyopro
提出日時 2021-08-13 21:30:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 356 bytes
コンパイル時間 326 ms
コンパイル使用メモリ 82,556 KB
実行使用メモリ 85,396 KB
最終ジャッジ日時 2024-04-14 16:48:34
合計ジャッジ時間 4,302 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
52,240 KB
testcase_01 AC 36 ms
52,604 KB
testcase_02 AC 61 ms
69,188 KB
testcase_03 AC 35 ms
52,756 KB
testcase_04 AC 36 ms
52,932 KB
testcase_05 AC 42 ms
60,380 KB
testcase_06 AC 47 ms
62,616 KB
testcase_07 AC 40 ms
59,688 KB
testcase_08 AC 61 ms
71,400 KB
testcase_09 AC 61 ms
70,300 KB
testcase_10 AC 65 ms
69,712 KB
testcase_11 AC 61 ms
69,788 KB
testcase_12 AC 64 ms
70,248 KB
testcase_13 AC 87 ms
84,240 KB
testcase_14 AC 72 ms
74,296 KB
testcase_15 AC 88 ms
84,976 KB
testcase_16 AC 87 ms
84,116 KB
testcase_17 AC 88 ms
84,720 KB
testcase_18 AC 86 ms
83,392 KB
testcase_19 AC 85 ms
84,364 KB
testcase_20 AC 74 ms
74,560 KB
testcase_21 AC 85 ms
83,268 KB
testcase_22 AC 87 ms
84,536 KB
testcase_23 AC 85 ms
84,236 KB
testcase_24 AC 86 ms
84,144 KB
testcase_25 AC 90 ms
84,492 KB
testcase_26 AC 85 ms
84,112 KB
testcase_27 AC 88 ms
84,772 KB
testcase_28 AC 88 ms
84,720 KB
testcase_29 AC 86 ms
83,964 KB
testcase_30 AC 89 ms
85,396 KB
testcase_31 AC 88 ms
84,396 KB
testcase_32 AC 88 ms
84,972 KB
testcase_33 AC 99 ms
84,112 KB
testcase_34 AC 98 ms
83,180 KB
testcase_35 AC 98 ms
83,176 KB
testcase_36 AC 98 ms
83,836 KB
testcase_37 AC 98 ms
83,876 KB
testcase_38 AC 104 ms
84,720 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
a=[0]+list(map(int,input().split()))
suma=sum(a)
mod=998244353
dp=[[0]*(2*sum(a)+1000) for i in range(n+1)]
dp[0][0]=1
for i in range(1,n+1):
    for j in range(-suma-10,suma+10):
        dp[i][j]=dp[i-1][j-a[i]]+dp[i-1][j+a[i]]
        dp[i][j]%=mod

ans=0
for j in range(-suma-10,suma+10):
    ans+=abs(j)*dp[n][j]
    ans%=mod

print(ans)
0