QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 1024 MB 満点: 100

#3610. 袋鼠聚会

統計

一群袋鼠住在数轴上的房子里。它们都想观看“袋鼠碗”(Kangaroo Bowl)比赛!

由于并非所有的袋鼠都能挤进同一间房子,它们决定指定两只袋鼠,分别在各自的房子里举办派对。所有其他袋鼠都会选择前往距离自己最近的那个派对举办地;如果距离两地距离相等,则可以任意选择其中一个。

一只袋鼠从位置 $a$ 移动到位置 $b$ 需要消耗 $(a - b)^2$ 单位的能量。请计算在最优选择两个派对举办地的情况下,所有袋鼠消耗的能量总和的最小值。

输入格式

输入的第一行包含一个整数 $n$ ($2 \le n \le 50$),表示袋鼠的数量。

接下来的 $n$ 行,每行包含一个整数 $x$ ($-1,000 \le x \le 1,000$),表示其中一只袋鼠房子的位置。所有位置各不相同。

输出格式

输出一行,表示在最优选择两个派对举办地的情况下,所有袋鼠消耗的能量总和的最小值。

样例

样例输入 1

5
0
3
-3
10
11

样例输出 1

19

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.