結果

問題 No.609 Noelちゃんと星々
ユーザー roarisroaris
提出日時 2019-07-26 11:34:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 251 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,740 KB
実行使用メモリ 19,316 KB
最終ジャッジ日時 2023-09-15 00:14:10
合計ジャッジ時間 2,806 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
16,460 KB
testcase_01 AC 40 ms
12,344 KB
testcase_02 AC 32 ms
10,888 KB
testcase_03 AC 37 ms
11,984 KB
testcase_04 AC 26 ms
9,844 KB
testcase_05 AC 80 ms
18,432 KB
testcase_06 AC 71 ms
17,164 KB
testcase_07 AC 46 ms
13,440 KB
testcase_08 AC 21 ms
9,232 KB
testcase_09 AC 34 ms
11,304 KB
testcase_10 AC 55 ms
14,532 KB
testcase_11 AC 51 ms
14,216 KB
testcase_12 AC 61 ms
15,996 KB
testcase_13 AC 23 ms
9,516 KB
testcase_14 AC 18 ms
8,708 KB
testcase_15 AC 71 ms
17,136 KB
testcase_16 AC 82 ms
18,656 KB
testcase_17 AC 66 ms
16,496 KB
testcase_18 AC 32 ms
10,756 KB
testcase_19 AC 69 ms
17,212 KB
testcase_20 AC 83 ms
19,312 KB
testcase_21 AC 83 ms
19,204 KB
testcase_22 AC 82 ms
19,312 KB
testcase_23 AC 82 ms
19,316 KB
testcase_24 AC 82 ms
19,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def median(seq):
    if N % 2 == 1:
        return seq[(N-1)//2]
    else:
        return (seq[N//2-1]+seq[N//2]) / 2

N = int(input())
Y = list(sorted(map(int, input().split())))
med = median(Y)
ans = sum(abs(Y_i - med) for Y_i in Y)
print(int(ans))
0