結果

問題 No.1374 Absolute Game
ユーザー rin204rin204
提出日時 2022-04-16 15:50:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 365 bytes
コンパイル時間 184 ms
コンパイル使用メモリ 82,372 KB
実行使用メモリ 85,444 KB
最終ジャッジ日時 2024-06-07 14:28:16
合計ジャッジ時間 3,387 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,616 KB
testcase_01 AC 36 ms
52,948 KB
testcase_02 AC 38 ms
53,372 KB
testcase_03 AC 37 ms
52,740 KB
testcase_04 AC 38 ms
52,768 KB
testcase_05 AC 40 ms
51,932 KB
testcase_06 AC 43 ms
53,580 KB
testcase_07 AC 39 ms
52,740 KB
testcase_08 AC 55 ms
65,708 KB
testcase_09 AC 76 ms
78,488 KB
testcase_10 AC 85 ms
82,108 KB
testcase_11 AC 66 ms
72,968 KB
testcase_12 AC 55 ms
66,872 KB
testcase_13 AC 71 ms
76,848 KB
testcase_14 AC 85 ms
85,096 KB
testcase_15 AC 86 ms
85,444 KB
testcase_16 AC 88 ms
85,284 KB
testcase_17 AC 84 ms
85,044 KB
testcase_18 AC 82 ms
85,044 KB
testcase_19 AC 83 ms
85,052 KB
testcase_20 AC 55 ms
67,972 KB
testcase_21 AC 61 ms
71,892 KB
testcase_22 AC 83 ms
84,880 KB
testcase_23 AC 46 ms
60,940 KB
testcase_24 AC 51 ms
62,528 KB
testcase_25 AC 49 ms
63,216 KB
testcase_26 AC 61 ms
67,392 KB
testcase_27 AC 63 ms
71,244 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