結果
| 問題 | No.1645 AB's abs |
| コンテスト | |
| ユーザー |
回転
|
| 提出日時 | 2026-01-13 16:04:27 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 133 ms / 2,000 ms |
| コード長 | 430 bytes |
| 記録 | |
| コンパイル時間 | 362 ms |
| コンパイル使用メモリ | 82,324 KB |
| 実行使用メモリ | 79,284 KB |
| 最終ジャッジ日時 | 2026-01-13 16:04:34 |
| 合計ジャッジ時間 | 5,479 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 36 |
ソースコード
from collections import defaultdict
MOD = 998244353
N = int(input())
A = list(map(int,input().split()))
now = defaultdict(int)
now[0] = 1
for i in range(N):
next = defaultdict(int)
for j in now:
next[j + A[i]] += now[j]
next[j + A[i]] %= MOD
next[j - A[i]] += now[j]
next[j - A[i]] %= MOD
now,next = next,now
ans = 0
for i in now:
ans += abs(i) * now[i]
ans %= MOD
print(ans)
回転