結果
| 問題 |
No.1645 AB's abs
|
| コンテスト | |
| ユーザー |
H20
|
| 提出日時 | 2021-08-13 22:15:56 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 137 ms / 2,000 ms |
| コード長 | 340 bytes |
| コンパイル時間 | 240 ms |
| コンパイル使用メモリ | 81,968 KB |
| 実行使用メモリ | 78,436 KB |
| 最終ジャッジ日時 | 2024-10-03 19:38:07 |
| 合計ジャッジ時間 | 4,994 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 |
ソースコード
import collections
mod = 998244353
N = int(input())
A = list(map(int, input().split()))
d = collections.defaultdict(int)
d[0]=1
for a in A:
nextd = collections.defaultdict(int)
for k,v in d.items():
nextd[abs(k+a)]+=v
nextd[abs(k-a)]+=v
d = nextd
ans = 0
for k,v in d.items():
ans = (ans+k*v)%mod
print(ans)
H20