結果

問題 No.2835 Take and Flip
ユーザー LyricalMaestro
提出日時 2025-07-20 00:49:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 148 ms / 2,000 ms
コード長 377 bytes
コンパイル時間 580 ms
コンパイル使用メモリ 82,772 KB
実行使用メモリ 107,936 KB
最終ジャッジ日時 2025-07-20 00:49:52
合計ジャッジ時間 5,745 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

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


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

    A.sort()
    answer= 0
    for i in range(N):
        if i % 2 == 0:
            j = i // 2
            answer += A[- j - 1]
        else:
            j = (i - 1) // 2
            answer -= -A[j]
    print(answer)





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