結果
| 問題 | No.2835 Take and Flip |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-09 21:26:04 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 148 ms / 2,000 ms |
| コード長 | 191 bytes |
| 記録 | |
| コンパイル時間 | 205 ms |
| コンパイル使用メモリ | 85,760 KB |
| 実行使用メモリ | 118,528 KB |
| 最終ジャッジ日時 | 2026-04-03 20:25:58 |
| 合計ジャッジ時間 | 4,053 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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)
i+=1
print(X-Y)