結果

問題 No.609 Noelちゃんと星々
ユーザー ssmkzkssmkzk
提出日時 2019-07-03 14:59:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 302 bytes
コンパイル時間 688 ms
コンパイル使用メモリ 10,660 KB
実行使用メモリ 19,252 KB
最終ジャッジ日時 2023-10-13 09:56:37
合計ジャッジ時間 5,032 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
16,384 KB
testcase_01 AC 52 ms
12,136 KB
testcase_02 AC 41 ms
10,784 KB
testcase_03 AC 50 ms
11,900 KB
testcase_04 AC 32 ms
9,960 KB
testcase_05 AC 114 ms
18,476 KB
testcase_06 AC 98 ms
17,252 KB
testcase_07 AC 62 ms
13,336 KB
testcase_08 AC 25 ms
9,104 KB
testcase_09 AC 46 ms
11,388 KB
testcase_10 AC 75 ms
14,788 KB
testcase_11 AC 70 ms
14,120 KB
testcase_12 AC 87 ms
15,976 KB
testcase_13 AC 27 ms
9,396 KB
testcase_14 AC 20 ms
8,656 KB
testcase_15 AC 102 ms
17,228 KB
testcase_16 AC 117 ms
18,736 KB
testcase_17 AC 96 ms
16,408 KB
testcase_18 AC 40 ms
10,716 KB
testcase_19 AC 101 ms
17,204 KB
testcase_20 AC 121 ms
19,192 KB
testcase_21 AC 120 ms
19,188 KB
testcase_22 AC 119 ms
19,144 KB
testcase_23 AC 121 ms
19,252 KB
testcase_24 AC 115 ms
19,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
l = list(map(int, input().split()))

l.sort()
ck1 = 0
if len(l) % 2 == 0:
    ck = len(l) // 2
    ck1 = ck - 1
else:
    ck = (len(l)+1) // 2

ck = l[ck-1]
ck1 = l[max(ck1-1,0)]


ans = 0
ans1 = 0

for li in l:
    ans += abs(ck - li)
    ans1 += abs(ck1 - li)

print(min(ans, ans1))
0