結果

問題 No.609 Noelちゃんと星々
コンテスト
ユーザー GrayCoder
提出日時 2017-12-09 20:52:56
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 93 ms / 2,000 ms
+ 361µs
コード長 421 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 58 ms
コンパイル使用メモリ 15,104 KB
実行使用メモリ 28,148 KB
最終ジャッジ日時 2026-10-02 10:09:47
合計ジャッジ時間 4,107 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import Counter
from bisect import bisect

def main():
    N = int(input())
    Y = tuple(map(int, input().split()))

    if N == 1:
        print(0)
        return

    c = Counter(Y).most_common()
    y = sorted(Y)
    idx = N // 2
    dist = float('inf')
    for i in (c[0][0], y[idx]):
        n = 0
        for j in y:
            n += abs(i - j)
        dist = min(dist, n)

    print(dist)

main()
0