結果

問題 No.1374 Absolute Game
ユーザー brthyyjpbrthyyjp
提出日時 2022-01-28 19:07:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 310 bytes
コンパイル時間 492 ms
コンパイル使用メモリ 87,308 KB
実行使用メモリ 93,144 KB
最終ジャッジ日時 2023-08-28 17:00:11
合計ジャッジ時間 6,066 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,276 KB
testcase_01 AC 74 ms
71,104 KB
testcase_02 AC 76 ms
71,424 KB
testcase_03 AC 72 ms
71,100 KB
testcase_04 AC 72 ms
71,272 KB
testcase_05 AC 74 ms
71,488 KB
testcase_06 AC 70 ms
71,412 KB
testcase_07 AC 73 ms
71,372 KB
testcase_08 AC 125 ms
80,860 KB
testcase_09 AC 159 ms
88,540 KB
testcase_10 AC 186 ms
90,152 KB
testcase_11 AC 145 ms
84,992 KB
testcase_12 AC 128 ms
81,332 KB
testcase_13 AC 152 ms
86,724 KB
testcase_14 AC 172 ms
92,380 KB
testcase_15 AC 176 ms
92,780 KB
testcase_16 AC 179 ms
92,400 KB
testcase_17 AC 177 ms
93,144 KB
testcase_18 AC 177 ms
92,304 KB
testcase_19 AC 177 ms
93,136 KB
testcase_20 AC 127 ms
82,216 KB
testcase_21 AC 142 ms
84,424 KB
testcase_22 AC 170 ms
93,128 KB
testcase_23 AC 113 ms
77,984 KB
testcase_24 AC 116 ms
78,272 KB
testcase_25 AC 116 ms
78,628 KB
testcase_26 AC 128 ms
81,532 KB
testcase_27 AC 138 ms
83,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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))
0