結果
| 問題 |
No.2835 Take and Flip
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-06-08 10:30:48 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 150 ms / 2,000 ms |
| コード長 | 214 bytes |
| コンパイル時間 | 532 ms |
| コンパイル使用メモリ | 82,180 KB |
| 実行使用メモリ | 105,756 KB |
| 最終ジャッジ日時 | 2025-06-08 10:30:54 |
| 合計ジャッジ時間 | 6,309 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 |
ソースコード
from collections import deque
N = int(input())
A = deque(sorted(list(map(int,input().split()))))
ans = 0
for i in range(N):
if i%2==0:
ans += A.pop()
else:
ans -= A.popleft()*(-1)
print(ans)