結果

問題 No.609 Noelちゃんと星々
ユーザー neterukunneterukun
提出日時 2019-05-06 03:56:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 225 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 10,576 KB
実行使用メモリ 18,964 KB
最終ジャッジ日時 2023-09-08 18:23:06
合計ジャッジ時間 4,213 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
16,268 KB
testcase_01 AC 47 ms
12,332 KB
testcase_02 AC 37 ms
11,052 KB
testcase_03 AC 45 ms
11,900 KB
testcase_04 AC 29 ms
9,916 KB
testcase_05 AC 100 ms
18,484 KB
testcase_06 AC 88 ms
17,016 KB
testcase_07 AC 55 ms
13,396 KB
testcase_08 AC 24 ms
9,260 KB
testcase_09 AC 40 ms
11,280 KB
testcase_10 AC 67 ms
14,436 KB
testcase_11 AC 61 ms
14,236 KB
testcase_12 AC 73 ms
15,808 KB
testcase_13 AC 26 ms
9,616 KB
testcase_14 AC 19 ms
8,704 KB
testcase_15 AC 84 ms
17,208 KB
testcase_16 AC 96 ms
18,628 KB
testcase_17 AC 79 ms
16,436 KB
testcase_18 AC 36 ms
10,940 KB
testcase_19 AC 80 ms
16,928 KB
testcase_20 AC 98 ms
18,828 KB
testcase_21 AC 96 ms
18,888 KB
testcase_22 AC 97 ms
18,848 KB
testcase_23 AC 97 ms
18,924 KB
testcase_24 AC 97 ms
18,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int, input().split()))

a = sorted(a)
if n % 2 == 0:
    median = (a[n//2 - 1] + a[n//2]) / 2
else:
    median = a[n//2]

ans = 0
for i in range(n):
    ans += abs(a[i] - median)

print(int(ans))
0