結果
| 問題 |
No.3103 Butterfly Effect
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-04-16 15:35:03 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 728 bytes |
| コンパイル時間 | 472 ms |
| コンパイル使用メモリ | 81,408 KB |
| 実行使用メモリ | 64,640 KB |
| 最終ジャッジ日時 | 2025-04-16 15:39:59 |
| 合計ジャッジ時間 | 7,397 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 1 |
| other | RE * 50 |
ソースコード
n = int(input())
a = list(map(int, input().split()))
original_sum = sum(abs(x) for x in a)
if n == 0:
print(0)
exit()
max_val = max(a)
pos = a.index(max_val)
# Calculate contributions
contributions = [abs(max_val) - abs(x) for x in a]
# Compute max_ending_at_pos (left part)
max_ending = 0
current = 0
for i in range(pos - 1, -1, -1):
current += contributions[i]
if current > max_ending:
max_ending = current
# Compute max_starting_at_pos (right part)
max_starting = 0
current = 0
for i in range(pos + 1, n):
current += contributions[i]
if current > max_starting:
max_starting = current
total_gain = max_ending + max_starting
answer = original_sum + max(total_gain, 0)
print(answer)
lam6er