题目描述
After scrimping and saving for years, Farmer John has decided to build a new barn. He wants the barn to be highly accessible, and he knows the coordinates of the grazing spots of all N (2 ≤ N ≤ 10,000 cows. Each grazing spot is at a point with integer coordinates (Xi, Yi) (-10,000 ≤ Xi ≤ 10,000; -10,000 ≤ Yi ≤ 10,000). The hungry cows never graze in spots that are horizontally or vertically adjacent.
The barn must be placed at integer coordinates and cannot be on any cow's grazing spot. The inconvenience of the barn for any cow is given the Manhattan distance formula | X - Xi | + | Y - Yi|, where (X, Y) and (Xi, Yi) are the coordinates of the barn and the cow's grazing spot, respectively. Where should the barn be constructed in order to minimize the sum of its inconvenience for all the cows?
经过多年的积蓄,农夫约翰决定造一个新的牛舍。他知道所有N(2 ≤ N ≤ 10,000)头牛的吃草位置,所以他想把牛舍造在最方便的地方。每一头牛吃草的位置是一个整数点(Xi, Yi)(-10,000 ≤ Xi ≤ 10,000; -10,000 ≤ Yi ≤ 10,000)。没有两头牛的吃草位置是相邻的。
约翰决定把牛舍造在一个没有牛吃草的整数点上,如果牛舍在(X, Y),在(Xi, Yi)的牛到牛舍的距离是| X - Xi | + | Y - Yi|,约翰把牛舍造在哪儿才能使所有牛到牛舍的距离和最小。
输入格式:
Line 1: A single integer: N
Lines 2..N+1: Line i+1 contains two space-separated integers which are the grazing location (Xi, Yi) of cow i
第1行:一个数N、
第2到N+1行:第i+1行包含第i头牛的位置(Xi, Yi)。
输出格式:
Line 1: Two space-separated integers: the minimum inconvenience for the barn and the number of spots on which Farmer John can build the barn to achieve this minimum.
一行,两个数,最小距离和 以及 所有可能达到这个距离和的牛舍位置的数目。
输入样例#1:
4
1 -3
0 1
-2 1
1 -1
输出样例#1:
10 4