/ OPS / 题库 /

Move House

Move House

#描述#
After hard work,LilyOldBig have earned numerous money. And he bought lots of houses. Unfortunately, this days the thiefs are very crazy. The government announces a red warning about protecting property. Considering this background,LilyOldBig decides to moving all the houses to the same place.You know, moving house is a hard work. LilyOldBig wants to know how much energy shoud he spend in moving all these houses together with the optimum strategy.
To make things easy,we assume moving a house from place(x1,y1) to place(x2,y2) will cost him |x1-x2|+|y1-y2| energy.and the initial place of a house is on a integer point ( xIsInt,yIsInt),also LilyOldBig only can move a house to a integer point(xIsInt,yIsInt) too.
If x is a integer and y is a integer,then (x,y) is a integer point.

#格式#
##输入格式##
The input contains multiple test cases.
For each case,first input N (1&lt=N&lt=10,000),which denoting the number of houses LilyOldBig have bought.Following N lines each line contain a integer point xi yi (0&lt=xi,yi&lt=10,000),denoting the place of the ith house.

##输出格式##
For each case, print the minimum energy that LilyOldBig should spend in moving all the houses to the same place.

#样例1#
##样例输入1##

2
10000 2000
10000 2000
4
1 2
2 1
2 3
3 2

##样例输出1##

0
4

#限制#
1000ms
32768KB

#提示#

#来源#
moonlight

信息

ID
1458
难度
5
分类
category1 点击显示
标签
递交数
0
已通过
0
通过率
?
上传者