当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3516:Tree Construction

题目描述
Consider a two-dimensional space with a set of points (xi, yi) that satisfy xi < xj and yi > yj for all i < j. We want to have them all connected by a directed tree whose edges go toward either right (x positive) or upward (y positive). The figure below shows an example tree.


Write a program that finds a tree connecting all given points with the shortest total length of edges.
输入解释
The input begins with a line that contains an integer n (1 <= n <= 1000), the number of points. Then n lines follow. The i-th line contains two integers xi and yi (0 <= xi, yi <= 10000), which give the coordinates of the i-th point.
输出解释
Print the total length of edges in a line.
输入样例
5
1 5
2 4
3 3
4 2
5 1
1
10000 0
输出样例
12
0
来自杭电HDUOJ的附加信息
Recommend zhouzeyong

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3516

最后修改于 2020-10-25T23:04:20+00:00 由爬虫自动更新

共提交 1

通过率 0.0%
时间上限 内存上限
4000/2000MS(Java/Others) 65536/32768K(Java/Others)