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

建议使用的浏览器:

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

3212:Rescue Alice

题目描述

Long long ago, there was a princess named Alice. She was taken by the evil Cent Dragon. Many warriors had tried to rescue her, but none of them ever came back. One day, a prince called Jack showed up. He told the King that he would go to rescue Alice in voluntary. The King responded in despair, “It’s no use fighting with Cent Dragon.” But that did not stop Jack. He set off immediately for the rescue.

Jack rode his way to the mountain where Cent Dragon lived. Unfortunately, he lost himself in the forest before the mountain and was unable to find Cent Dragon’s castle. After wandering for a while, Jack saw an old man on a stone smiling at him. He was surprised by the encounter and asked the old man for the way. “The forest is cursed in spells. An ordinal human being won’t be able to find a way out.” said the old man, “If you want to go to Cent Dragon’s castle, you must find the Tree of Moon for help.”

In spite of hardships, Jack succeeded in locating the Tree of Moon – a big blue tree with spirits. He told his story to it, and it answered, “In this forest there are some magical wells. They are the entries of the mountain. You can see all of them on a high tower nearby. You choice of entry will decide how soon you can enter the mountain. Precisely speaking, the time it takes can be measured by the sum of the distances between the well you choose and the other ones.”

In that ancient times, distance was measured in a manner similar to what we now call the Manhattan distance. Positions of the wells were described in a Cartesian plane. Instead of taking the sum of absolute differences in the abscissa and the ordinate, distances in Jack’s adventure were found by taking the maximum of them. Given the coordinates of the wells, can you tell how much time did Jack need at least to spend entering the mountain to rescue Alice in terms of distance?

输入解释

The input contains a single test case. The first line of input contains a positive integer N (N ≤ 100,000), the number of wells. Then follow N lines, each contains two integers xi and yi (|xi|, |yi| ≤ 1,000,000), which are the Cartesian coordinate of the ith well.

输出解释

Output one line containing only the minimum time Jack needed for entry into the mountain.

输入样例
4
0 1
2 5
3 1
4 0
输出样例
8
提示

Sums of distances of the wells are 11, 13, 8 and 10. 8 is the minimum.


该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3212

最后修改于 2020-10-29T06:55:55+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
3000 131072