結果

問題 No.1645 AB's abs
ユーザー playerplayer
提出日時 2023-12-23 00:23:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 571 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 82,372 KB
最終ジャッジ日時 2023-12-23 00:23:55
合計ジャッジ時間 5,855 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
64,456 KB
testcase_01 AC 51 ms
62,184 KB
testcase_02 AC 77 ms
71,424 KB
testcase_03 AC 47 ms
62,184 KB
testcase_04 AC 53 ms
64,452 KB
testcase_05 AC 53 ms
64,760 KB
testcase_06 AC 58 ms
65,380 KB
testcase_07 AC 53 ms
64,604 KB
testcase_08 AC 78 ms
72,828 KB
testcase_09 AC 78 ms
72,828 KB
testcase_10 AC 77 ms
72,204 KB
testcase_11 AC 77 ms
72,204 KB
testcase_12 AC 77 ms
72,360 KB
testcase_13 AC 108 ms
82,060 KB
testcase_14 AC 113 ms
81,120 KB
testcase_15 AC 110 ms
82,060 KB
testcase_16 AC 110 ms
81,436 KB
testcase_17 AC 106 ms
81,904 KB
testcase_18 AC 103 ms
81,276 KB
testcase_19 AC 106 ms
82,060 KB
testcase_20 AC 103 ms
80,808 KB
testcase_21 AC 105 ms
81,436 KB
testcase_22 AC 106 ms
81,904 KB
testcase_23 AC 110 ms
82,372 KB
testcase_24 AC 114 ms
82,372 KB
testcase_25 AC 108 ms
82,372 KB
testcase_26 AC 108 ms
82,372 KB
testcase_27 AC 108 ms
82,372 KB
testcase_28 AC 107 ms
82,372 KB
testcase_29 AC 109 ms
82,372 KB
testcase_30 AC 109 ms
82,372 KB
testcase_31 AC 110 ms
82,372 KB
testcase_32 AC 110 ms
82,372 KB
testcase_33 AC 106 ms
81,856 KB
testcase_34 AC 125 ms
81,860 KB
testcase_35 AC 106 ms
81,856 KB
testcase_36 AC 107 ms
81,856 KB
testcase_37 AC 106 ms
81,856 KB
testcase_38 AC 106 ms
81,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int,input().split()))
mod = 998244353

dp = [[0 for _ in range(2*10**4+2)] for _ in range(n+1)]
dp[0][10**4] = 1
for i in range(n):
    for j in range(2*10**4+2):
        if 0 <= j-a[i] <= 2*10**4+1:
            dp[i+1][j] += dp[i][j-a[i]]
        if 0 <= j+a[i] <= 2*10**4+1:
            dp[i+1][j] += dp[i][j+a[i]]
            
        dp[i+1][j] %= mod
        
ans = 0
st = 10**4
for i in range(2*10**4+2):
    num = (i-st)*dp[n][i]
    # if num != 0:
    #     print(i,num)
    ans += abs((i-st))*dp[n][i]
    ans %= mod
    
print(ans)
0