货仓选址
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
货仓选址
题目描述
在一条数轴上有 家商店,它们的坐标分别为 。现在需要在数轴上建立一家货仓,每天清晨,从货仓到每家商店都要运送一车商品。为了提高效率,求把货仓建在何处,可以使得货仓到每家商店的距离之和最小。
输入格式
第一行一个整数 。
第二行 个整数 。
输出格式
一个整数,表示距离之和的最小值。
样例 #1
样例输入 #1
4
6 2 9 1
样例输出 #1
12
数据范围
对于 的数据,,(本包数据的坐标取值为 )。
提示
答案可能超过 ,请注意使用 64 位整数。
2026swpuacm秋招复赛-终结版
- Status
- Done
- Rule
- XCPC
- Problem
- 9
- Start at
- 2026-10-31 9:00
- End at
- 2026-10-31 12:00
- Duration
- 3 hour(s)
- Host
- Partic.
- 28