結果

問題 No.3268 As Seen in Toasters
コンテスト
ユーザー LyricalMaestro
提出日時 2025-12-11 01:01:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 576 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 346 ms
コンパイル使用メモリ 82,348 KB
実行使用メモリ 118,904 KB
最終ジャッジ日時 2025-12-11 01:01:22
合計ジャッジ時間 7,236 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 26 WA * 9 RE * 6
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

## https://yukicoder.me/problems/no/3268


def main():
    N = int(input())
    A = list(map(int, input().split()))

    a_positive = []
    a_negative = []
    for a in A:
        if a >= 0:
            a_positive.append(a)
        else:
            a_negative.append(a)
    
    a_negative.sort()
    a_positive.sort()

    answer = 0
    for i in range(1, len(a_negative)):
        answer += - a_negative[i - 1] - a_negative[i]
    p = a_negative[-1]
    for a in a_positive:
        answer += a - p
        p = a
    print(answer)




if __name__ == '__main__':
    main()
0