結果
| 問題 |
No.609 Noelちゃんと星々
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-09 16:21:07 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 591 bytes |
| コンパイル時間 | 99 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 27,664 KB |
| 最終ジャッジ日時 | 2024-11-30 04:44:03 |
| 合計ジャッジ時間 | 4,272 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 25 |
ソースコード
from collections import Counter
from bisect import bisect
def main():
N = int(input())
Y = tuple(map(int, input().split()))
c = Counter(Y).most_common()
if len(c) == 1:
print(0)
return
elif len(c) == 2:
print((c[0][0] - c[1][0]) * c[1][1])
return
else:
y = sorted(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:
n += abs(i - j) * k
dist = min(dist, n)
print(dist)
main()