結果

問題 No.1374 Absolute Game
ユーザー roarisroaris
提出日時 2021-03-02 16:28:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 277 bytes
コンパイル時間 311 ms
コンパイル使用メモリ 82,424 KB
実行使用メモリ 93,648 KB
最終ジャッジ日時 2024-04-14 04:42:42
合計ジャッジ時間 3,629 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,280 KB
testcase_01 AC 37 ms
52,400 KB
testcase_02 AC 36 ms
52,616 KB
testcase_03 AC 38 ms
52,604 KB
testcase_04 AC 36 ms
52,216 KB
testcase_05 AC 36 ms
53,128 KB
testcase_06 AC 36 ms
53,020 KB
testcase_07 AC 37 ms
53,384 KB
testcase_08 AC 55 ms
71,108 KB
testcase_09 AC 72 ms
79,184 KB
testcase_10 AC 78 ms
82,080 KB
testcase_11 AC 66 ms
78,648 KB
testcase_12 AC 56 ms
68,052 KB
testcase_13 AC 68 ms
76,372 KB
testcase_14 AC 81 ms
84,788 KB
testcase_15 AC 88 ms
92,476 KB
testcase_16 AC 82 ms
84,096 KB
testcase_17 AC 87 ms
92,364 KB
testcase_18 AC 80 ms
84,960 KB
testcase_19 AC 87 ms
92,496 KB
testcase_20 AC 57 ms
74,220 KB
testcase_21 AC 64 ms
76,216 KB
testcase_22 AC 86 ms
93,648 KB
testcase_23 AC 45 ms
64,520 KB
testcase_24 AC 46 ms
63,864 KB
testcase_25 AC 46 ms
64,168 KB
testcase_26 AC 52 ms
68,504 KB
testcase_27 AC 58 ms
72,132 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N = int(input())
c = list(map(int, input().split()))

if sum(c)<0:
    c = list(map(lambda x: -x, c))

c.sort(reverse=True)
a, b = 0, 0

for i in range(N):
    if i%2==0:
        a += c[i]
    else:
        b += c[i]

print(abs(a)-abs(b))
0