結果

問題 No.3268 As Seen in Toasters
ユーザー amesyu
提出日時 2025-09-12 22:06:04
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 395 bytes
コンパイル時間 373 ms
コンパイル使用メモリ 82,216 KB
実行使用メモリ 121,324 KB
最終ジャッジ日時 2025-09-12 23:40:13
合計ジャッジ時間 5,872 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 32 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

# 端は寄与が1


def f(x, y):
    if x < 0 and y < 0:
        return -x - y
    return abs(x - y)


n = int(input())
a = list(map(int, input().split()))

pos = []
neg = []

for v in a:
    if v > 0:
        pos.append(v)
    else:
        neg.append(v)

pos.sort(reverse=True)
neg.sort(reverse=True)
arr = pos + neg
ans = 0
for i in range(1, n):
    ans += f(arr[i - 1], arr[i])

print(ans)
0