結果
問題 |
No.609 Noelちゃんと星々
|
ユーザー |
|
提出日時 | 2017-12-09 13:49:18 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 565 bytes |
コンパイル時間 | 89 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 26,736 KB |
最終ジャッジ日時 | 2024-11-30 02:17:40 |
合計ジャッジ時間 | 3,839 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 25 |
ソースコード
from collections import Counter from bisect import bisect def main(): N = int(input()) Y = tuple(map(int, input().split())) y = sorted(Y) if N == 1: print(y[0]) return elif N == 2: print(abs(y[1] - y[0])) return else: c = Counter(Y) dist = float('inf') mid = (y[0] + y[1]) / 2 x = bisect(y, mid) for i in (y[x], y[x-1]): n = 0 for j, k in c.items(): n += abs(i - j) * k dist = min(dist, n) print(dist) main()