結果

問題 No.1374 Absolute Game
ユーザー pluto77pluto77
提出日時 2021-03-20 11:34:09
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 188 bytes
コンパイル時間 127 ms
コンパイル使用メモリ 10,492 KB
実行使用メモリ 19,276 KB
最終ジャッジ日時 2023-08-13 03:56:01
合計ジャッジ時間 4,216 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,784 KB
testcase_01 AC 16 ms
7,756 KB
testcase_02 AC 15 ms
7,940 KB
testcase_03 AC 16 ms
7,744 KB
testcase_04 AC 16 ms
7,808 KB
testcase_05 AC 15 ms
7,896 KB
testcase_06 AC 15 ms
7,828 KB
testcase_07 AC 15 ms
7,900 KB
testcase_08 AC 39 ms
11,428 KB
testcase_09 AC 80 ms
16,328 KB
testcase_10 AC 88 ms
17,352 KB
testcase_11 AC 61 ms
13,752 KB
testcase_12 AC 40 ms
11,660 KB
testcase_13 AC 70 ms
15,392 KB
testcase_14 AC 101 ms
19,096 KB
testcase_15 AC 105 ms
19,244 KB
testcase_16 AC 101 ms
19,096 KB
testcase_17 AC 106 ms
19,156 KB
testcase_18 AC 101 ms
19,192 KB
testcase_19 AC 103 ms
19,276 KB
testcase_20 AC 44 ms
12,532 KB
testcase_21 AC 57 ms
13,524 KB
testcase_22 AC 101 ms
18,520 KB
testcase_23 AC 24 ms
9,384 KB
testcase_24 AC 27 ms
9,632 KB
testcase_25 AC 28 ms
10,032 KB
testcase_26 AC 40 ms
11,700 KB
testcase_27 AC 51 ms
13,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki1374
n=int(input())
a=list(map(int,input().split()))
if sum(a)<0:
 a=[-i for i in a]
a.sort()
x=0
y=0
f=1
while a:
 if f:
  x+=a.pop()
 else:
  y+=a.pop()
 f=1-f
print(abs(x)-abs(y))
0