結果

問題 No.1374 Absolute Game
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-02-05 22:41:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 381 bytes
コンパイル時間 525 ms
コンパイル使用メモリ 10,848 KB
実行使用メモリ 18,980 KB
最終ジャッジ日時 2023-09-15 09:21:43
合計ジャッジ時間 3,427 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,856 KB
testcase_01 AC 16 ms
7,908 KB
testcase_02 AC 16 ms
7,816 KB
testcase_03 AC 15 ms
7,696 KB
testcase_04 WA -
testcase_05 AC 16 ms
7,824 KB
testcase_06 AC 16 ms
7,700 KB
testcase_07 AC 15 ms
7,836 KB
testcase_08 WA -
testcase_09 AC 84 ms
16,216 KB
testcase_10 AC 94 ms
17,372 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 75 ms
15,244 KB
testcase_14 AC 111 ms
18,812 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 107 ms
18,828 KB
testcase_19 WA -
testcase_20 AC 46 ms
12,036 KB
testcase_21 AC 60 ms
13,528 KB
testcase_22 AC 108 ms
18,596 KB
testcase_23 AC 24 ms
9,404 KB
testcase_24 WA -
testcase_25 AC 30 ms
9,924 KB
testcase_26 AC 41 ms
11,568 KB
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

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(a) - abs(b))
0