結果
| 問題 |
No.3185 Three Abs
|
| コンテスト | |
| ユーザー |
detteiuu
|
| 提出日時 | 2025-06-20 21:56:54 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 618 bytes |
| コンパイル時間 | 407 ms |
| コンパイル使用メモリ | 82,840 KB |
| 実行使用メモリ | 172,492 KB |
| 最終ジャッジ日時 | 2025-06-20 21:57:07 |
| 合計ジャッジ時間 | 12,477 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 30 |
ソースコード
for _ in range(int(input())):
N = int(input())
A = list(map(int, input().split()))
cum = [0]
for a in A:
cum.append(cum[-1]+a)
MIN = [cum[-1]]
MAX = [cum[-1]]
for i in reversed(range(1, N)):
MIN.append(min(MIN[-1], cum[i]))
MAX.append(max(MAX[-1], cum[i]))
MIN = MIN[::-1]
MAX = MAX[::-1]
ans = 0
for i in range(N-2):
cumL = cum[i+1]
cumR = cum[-1]-cum[i+1]
minSUM = MIN[i+1]-cumL
maxSUM = MAX[i+1]-cumL
ans = max(ans, cumL+max(abs(minSUM)+abs(cumR-minSUM), abs(maxSUM)+abs(cumR-maxSUM)))
print(ans)
detteiuu