結果

問題 No.1374 Absolute Game
ユーザー titiatitia
提出日時 2021-02-07 13:29:14
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 257 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,624 KB
実行使用メモリ 19,184 KB
最終ジャッジ日時 2023-09-17 04:11:34
合計ジャッジ時間 3,050 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,832 KB
testcase_01 AC 16 ms
7,752 KB
testcase_02 AC 15 ms
7,836 KB
testcase_03 AC 16 ms
7,832 KB
testcase_04 AC 15 ms
7,836 KB
testcase_05 AC 16 ms
7,884 KB
testcase_06 AC 16 ms
7,756 KB
testcase_07 AC 16 ms
7,768 KB
testcase_08 AC 38 ms
11,340 KB
testcase_09 AC 77 ms
16,180 KB
testcase_10 AC 89 ms
17,440 KB
testcase_11 AC 61 ms
13,756 KB
testcase_12 AC 40 ms
11,700 KB
testcase_13 AC 69 ms
15,200 KB
testcase_14 AC 101 ms
19,036 KB
testcase_15 AC 105 ms
19,056 KB
testcase_16 AC 100 ms
19,184 KB
testcase_17 AC 106 ms
19,096 KB
testcase_18 AC 102 ms
19,056 KB
testcase_19 AC 106 ms
19,156 KB
testcase_20 AC 44 ms
12,612 KB
testcase_21 AC 55 ms
13,312 KB
testcase_22 AC 101 ms
18,456 KB
testcase_23 AC 23 ms
9,144 KB
testcase_24 AC 26 ms
9,728 KB
testcase_25 AC 28 ms
9,956 KB
testcase_26 AC 38 ms
11,500 KB
testcase_27 AC 50 ms
13,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

if sum(A)<0:
    A=[-a for a in A]

A.sort(reverse=True)

X=0
Y=0
for i in range(len(A)):
    if i%2==0:
        X+=A[i]
    else:
        Y+=A[i]

print(abs(X)-abs(Y))
0