結果

問題 No.3103 Butterfly Effect
ユーザー gew1fw
提出日時 2025-06-12 18:35:36
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 599 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 82,788 KB
実行使用メモリ 67,504 KB
最終ジャッジ日時 2025-06-12 18:36:05
合計ジャッジ時間 11,565 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 1
other RE * 50
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))
if n == 0:
    print(0)
    exit()
M = max(a)
m = min(a)
max_abs = max(abs(M), abs(m))

total = 0
for num in a:
    if max_abs == abs(M):
        if abs(num) < abs(M):
            total += abs(M)
        else:
            total += abs(num)
    else:
        if num == m:
            total += abs(m)
        else:
            if abs(num) >= abs(m):
                total += abs(num)
            else:
                if abs(M) > abs(num):
                    total += abs(M)
                else:
                    total += abs(num)
print(total)
0