CF50C.Happy Farm 5
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The Happy Farm 5 creators decided to invent the mechanism of cow grazing. The cows in the game are very slow and they move very slowly, it can even be considered that they stand still. However, carnivores should always be chased off them.
For that a young player Vasya decided to make the shepherd run round the cows along one and the same closed path. It is very important that the cows stayed strictly inside the area limited by the path, as otherwise some cows will sooner or later be eaten. To be absolutely sure in the cows' safety, Vasya wants the path completion time to be minimum.
The new game is launched for different devices, including mobile phones. That's why the developers decided to quit using the arithmetics with the floating decimal point and use only the arithmetics of integers. The cows and the shepherd in the game are represented as points on the plane with integer coordinates. The playing time is modeled by the turns. During every turn the shepherd can either stay where he stands or step in one of eight directions: horizontally, vertically, or diagonally. As the coordinates should always remain integer, then the length of a horizontal and vertical step is equal to 1, and the length of a diagonal step is equal to
. The cows do not move. You have to minimize the number of moves the shepherd needs to run round the whole herd.
《快乐农场5》的开发者决定设计一套奶牛放牧机制。游戏中,奶牛行动极为缓慢,甚至可视为静止不动。然而,食肉动物必须始终被驱离奶牛。
为此,一位名叫瓦夏的年轻玩家决定让牧羊人沿一条固定且封闭的路径绕着所有奶牛奔跑。至关重要的是:所有奶牛必须严格位于该路径所围成区域的内部,否则迟早会有奶牛被吃掉。为确保奶牛绝对安全,瓦夏希望该路径的完成时间最短。
新游戏将面向包括手机在内的多种设备发布。因此,开发者决定弃用浮点数运算,仅使用整数运算。游戏中,奶牛与牧羊人均表示为平面上具有整数坐标的点。游戏时间以“回合”建模:在每一回合中,牧羊人可选择原地不动,或向八个方向之一移动一步(水平、垂直或对角线方向)。由于坐标必须始终保持为整数,故水平或垂直方向的步长为 1,而对角线方向的步长为
。奶牛不移动。你需要最小化牧羊人绕完整个牛群所需执行的移动步数。
输入格式
The first line contains an integer N which represents the number of cows in the herd (1 ≤ N ≤ 105). Each of the next N lines contains two integers X__i and Y__i which represent the coordinates of one cow of (|X__i|, |Y__i| ≤ 106). Several cows can stand on one point.
第一行包含一个整数 N,表示牛群中奶牛的数量(1 ≤ N ≤ 105)。接下来的 N 行中,每行包含两个整数 Xi 和 Yi,表示一头奶牛的坐标(满足 ∣Xi∣,∣Yi∣ ≤ 106)。多头奶牛可以位于同一点上。
输出格式
Print the single number — the minimum number of moves in the sought path.
输出单个数字——所求路径中的最小移动次数。
输入输出样例
输入#1
4 1 1 5 1 5 3 1 3
输出#1
16
说明/提示
Picture for the example test: The coordinate grid is painted grey, the coordinates axes are painted black, the cows are painted red and the sought route is painted green.

示例测试的示意图:坐标网格为灰色,坐标轴为黑色,奶牛为红色,所求路径为绿色。

输入解题思路,AI测评打分。不知道怎么写?