結果
| 問題 |
No.2835 Take and Flip
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-09 21:25:01 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 151 ms / 2,000 ms |
| コード長 | 182 bytes |
| コンパイル時間 | 157 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 105,088 KB |
| 最終ジャッジ日時 | 2024-08-09 21:25:09 |
| 合計ジャッジ時間 | 3,865 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
from collections import deque
N=int(input())
A=list(map(int,input().split()))
A=deque(sorted(A))
X=0
Y=0
i=0
while A:
if i%2==0:X+=A.pop()
else:Y+=A.popleft()*(-1)
print(X-Y)