結果

問題 No.1374 Absolute Game
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2021-02-27 11:37:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 223 bytes
コンパイル時間 198 ms
コンパイル使用メモリ 82,312 KB
実行使用メモリ 86,656 KB
最終ジャッジ日時 2024-04-10 15:34:45
合計ジャッジ時間 2,808 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
51,840 KB
testcase_01 AC 32 ms
52,480 KB
testcase_02 AC 33 ms
51,968 KB
testcase_03 AC 34 ms
52,352 KB
testcase_04 AC 34 ms
51,968 KB
testcase_05 AC 32 ms
51,712 KB
testcase_06 AC 31 ms
52,096 KB
testcase_07 AC 31 ms
52,224 KB
testcase_08 AC 47 ms
67,712 KB
testcase_09 AC 68 ms
79,616 KB
testcase_10 AC 67 ms
82,176 KB
testcase_11 AC 56 ms
74,240 KB
testcase_12 AC 48 ms
67,840 KB
testcase_13 AC 66 ms
77,056 KB
testcase_14 AC 78 ms
85,120 KB
testcase_15 AC 77 ms
86,016 KB
testcase_16 AC 75 ms
85,248 KB
testcase_17 AC 76 ms
86,656 KB
testcase_18 AC 73 ms
85,120 KB
testcase_19 AC 74 ms
86,656 KB
testcase_20 AC 50 ms
69,760 KB
testcase_21 AC 55 ms
73,216 KB
testcase_22 AC 73 ms
86,656 KB
testcase_23 AC 40 ms
62,976 KB
testcase_24 AC 40 ms
63,360 KB
testcase_25 AC 41 ms
64,384 KB
testcase_26 AC 49 ms
68,096 KB
testcase_27 AC 54 ms
71,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int,input().split()))
if sum(a) < 0:
    a = [-1*i for i in a]
a.sort(reverse=True)
A = 0
B = 0
for i in range(n):
    if i%2:
        B += a[i]
    else:
        A += a[i]
print(abs(A)-abs(B))
0