結果

問題 No.1374 Absolute Game
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-02-05 22:42:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 386 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 10,784 KB
実行使用メモリ 19,336 KB
最終ジャッジ日時 2023-09-15 09:22:20
合計ジャッジ時間 3,342 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,864 KB
testcase_01 AC 17 ms
7,820 KB
testcase_02 AC 16 ms
7,864 KB
testcase_03 AC 16 ms
7,896 KB
testcase_04 AC 16 ms
7,924 KB
testcase_05 AC 16 ms
7,852 KB
testcase_06 AC 16 ms
7,908 KB
testcase_07 AC 16 ms
7,804 KB
testcase_08 WA -
testcase_09 AC 89 ms
16,356 KB
testcase_10 AC 98 ms
17,396 KB
testcase_11 WA -
testcase_12 AC 44 ms
11,612 KB
testcase_13 AC 76 ms
15,284 KB
testcase_14 AC 108 ms
19,148 KB
testcase_15 AC 108 ms
19,332 KB
testcase_16 AC 108 ms
19,160 KB
testcase_17 AC 110 ms
19,144 KB
testcase_18 AC 113 ms
19,336 KB
testcase_19 AC 110 ms
19,308 KB
testcase_20 AC 48 ms
12,232 KB
testcase_21 AC 61 ms
13,472 KB
testcase_22 AC 113 ms
18,644 KB
testcase_23 AC 24 ms
9,384 KB
testcase_24 AC 28 ms
9,688 KB
testcase_25 AC 30 ms
10,068 KB
testcase_26 AC 42 ms
11,596 KB
testcase_27 AC 54 ms
13,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
c = list(map(int, input().split()))
c.sort()
sei = [i for i in c if i >= 0]
sei.sort()
hu = [i for i in c if i < 0]
hu.sort()
a, b = 0, 0
for i in range(len(sei)):
    if i % 2:
        b += sei[i]
    else:
        a += sei[i]
seile = len(sei)
for i in range(len(hu)):
    if (i + seile) % 2:
        b += hu[i]
    else:
        a += hu[i]
print(abs(abs(a) - abs(b)))
0