結果

問題 No.1374 Absolute Game
ユーザー rlangevinrlangevin
提出日時 2023-06-15 08:59:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 254 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 87,008 KB
実行使用メモリ 92,340 KB
最終ジャッジ日時 2023-09-05 15:15:15
合計ジャッジ時間 5,888 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,444 KB
testcase_01 AC 75 ms
71,200 KB
testcase_02 AC 74 ms
71,444 KB
testcase_03 AC 73 ms
71,444 KB
testcase_04 AC 75 ms
71,420 KB
testcase_05 AC 76 ms
71,448 KB
testcase_06 AC 73 ms
71,576 KB
testcase_07 AC 75 ms
71,200 KB
testcase_08 AC 93 ms
79,352 KB
testcase_09 AC 109 ms
88,112 KB
testcase_10 AC 112 ms
89,844 KB
testcase_11 AC 101 ms
83,684 KB
testcase_12 AC 94 ms
79,788 KB
testcase_13 AC 107 ms
86,100 KB
testcase_14 AC 120 ms
92,044 KB
testcase_15 AC 121 ms
91,964 KB
testcase_16 AC 116 ms
91,824 KB
testcase_17 AC 119 ms
92,116 KB
testcase_18 AC 116 ms
91,936 KB
testcase_19 AC 117 ms
92,340 KB
testcase_20 AC 95 ms
81,276 KB
testcase_21 AC 100 ms
82,972 KB
testcase_22 AC 118 ms
92,328 KB
testcase_23 AC 82 ms
76,268 KB
testcase_24 AC 85 ms
76,796 KB
testcase_25 AC 88 ms
77,296 KB
testcase_26 AC 90 ms
80,096 KB
testcase_27 AC 96 ms
82,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
C = list(map(int, input().split()))
if sum(C) < 0:
    for i in range(N):
        C[i] = -C[i]

a, b = 0, 0
C.sort(reverse=True)
for i in range(N):
    if i % 2 == 0:
        a += C[i]
    else:
        b += C[i]

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