結果
| 問題 |
No.837 Noelちゃんと星々2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-07-11 09:52:13 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 412 bytes |
| コンパイル時間 | 190 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 34,340 KB |
| 最終ジャッジ日時 | 2024-11-07 07:02:07 |
| 合計ジャッジ時間 | 7,331 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 4 |
| other | TLE * 1 -- * 28 |
ソースコード
n = int(input())
l = sorted(map(int, input().split()))
if len(set(l)) == 1:
print(1)
else:
ans = []
for i in range(1, n):
x = l[:i]
y = l[i:]
a = x[len(x)//2]
b = 0
for i in x:
b += abs(a-i)
c = y[len(y)//2]
d = 0
for i in y:
d += abs(c-i)
ans.append(b+d)
print(min(ans))