結果
問題 | No.1374 Absolute Game |
ユーザー | brthyyjp |
提出日時 | 2022-01-28 19:07:59 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 182 ms / 2,000 ms |
コード長 | 310 bytes |
コンパイル時間 | 311 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 91,904 KB |
最終ジャッジ日時 | 2024-12-29 22:32:21 |
合計ジャッジ時間 | 5,376 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 26 |
ソースコード
n = int(input()) C = list(map(int, input().split())) s = sum(C) if s < 0: C = [-c for c in C] import heapq q = [] heapq.heapify(q) for c in C: heapq.heappush(q, -c) a = 0 b = 0 for i in range(n): v = -heapq.heappop(q) if i%2 == 0: a += v else: b += v print(abs(a)-abs(b))