#Lutece1043. Just a simple problem
Just a simple problem
Migrated from Lutece 1043 Just a simple problem
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
There are points (whose coordinates are both integers) in a two-dimension plane.
Now you have a rectangle frame with size , you can move it only in the horizontal and vertical direction. That is to say, you can't rotate the frame.
When the frame are at some place, every point will produce a cost. The total cost is the sum of all points' cost.
Please calculate the minimum total cost.
The cost produced by point is calculated in the following way.
If is inside the frame, the cost is . Else, the cost is the minimum Manhattan distance between and a point on the frame.
The Manhattan distance between and is
Input
The first line contains a single integer , which is the number of points.
The second line contains integers and , is the height of the frame, and is the width of the frame.
Each of the following lines contains integers and , which are the coordinates of the point.
$1 \leq n \leq 100000, 1 \leq x_i, y_i, H, W \leq 100000$
Output
Print the minimum total cost in one line.
Samples
6
3 7
1 7
4 10
9 2
6 5
8 7
10 1
10
Note
The solution of sample input
Resources
The 13th UESTC Programming Contest Preliminary