結果

問題 No.3103 Butterfly Effect
ユーザー gew1fw
提出日時 2025-06-12 13:25:42
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 599 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 82,600 KB
実行使用メモリ 67,592 KB
最終ジャッジ日時 2025-06-12 13:32:06
合計ジャッジ時間 8,360 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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