結果

問題 No.1374 Absolute Game
ユーザー 👑 rin204rin204
提出日時 2022-04-16 15:50:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 365 bytes
コンパイル時間 594 ms
コンパイル使用メモリ 87,116 KB
実行使用メモリ 92,544 KB
最終ジャッジ日時 2023-08-26 18:56:16
合計ジャッジ時間 5,351 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,300 KB
testcase_01 AC 67 ms
71,020 KB
testcase_02 AC 68 ms
71,192 KB
testcase_03 AC 68 ms
71,400 KB
testcase_04 AC 71 ms
71,192 KB
testcase_05 AC 71 ms
71,236 KB
testcase_06 AC 71 ms
71,332 KB
testcase_07 AC 69 ms
71,244 KB
testcase_08 AC 83 ms
78,576 KB
testcase_09 AC 102 ms
88,188 KB
testcase_10 AC 103 ms
89,992 KB
testcase_11 AC 92 ms
83,792 KB
testcase_12 AC 82 ms
79,292 KB
testcase_13 AC 97 ms
86,176 KB
testcase_14 AC 109 ms
92,172 KB
testcase_15 AC 112 ms
92,220 KB
testcase_16 AC 111 ms
92,544 KB
testcase_17 AC 110 ms
92,204 KB
testcase_18 AC 108 ms
92,164 KB
testcase_19 AC 108 ms
92,092 KB
testcase_20 AC 80 ms
80,516 KB
testcase_21 AC 90 ms
82,568 KB
testcase_22 AC 107 ms
92,180 KB
testcase_23 AC 73 ms
75,728 KB
testcase_24 AC 75 ms
76,012 KB
testcase_25 AC 76 ms
76,624 KB
testcase_26 AC 80 ms
79,176 KB
testcase_27 AC 85 ms
82,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""
b = sum(C) - a
合計値が0:
    答えも0
合計値が正:
    aを最大にしたい
合計値が負:
    aを最小にしたい
"""

n = int(input())
C = list(map(int, input().split()))
tot = sum(C)
if tot == 0:
    print(0)
    exit()
if tot > 0:
    C.sort(reverse = True)
else:
    C.sort()
a = sum(C[0::2])
b = sum(C[1::2])
print(abs(a) - abs(b))
0