結果

問題 No.2835 Take and Flip
ユーザー るこーそー
提出日時 2024-09-25 13:17:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 159 ms / 2,000 ms
コード長 212 bytes
コンパイル時間 359 ms
コンパイル使用メモリ 82,180 KB
実行使用メモリ 103,904 KB
最終ジャッジ日時 2024-09-25 13:17:43
合計ジャッジ時間 4,990 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

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

A.sort()
que=deque(A)

X,Y=0,0
for i in range(n):
    if i%2==0:
        X+=que.pop()
    else:
        Y-=que.popleft()

print(X-Y)
0