Rectangles cover
Submit solution
Points:
100
Time limit:
2.0s
Memory limit:
64M
Author:
Problem type
Allowed languages
Ada, Assembly, Awk, BrainF***, C, C#, C++, Dart, Go, Java, JS, Kotlin, Lua, Pascal, Perl, Prolog, Python, Scala, Swift, VB
You are given
- The sides of each rectangle are parallel with the coordinate axes,
- The center of each rectangle is in the origin, i.e. point
, - Each given point is located either inside of the rectangle or on its boundaries.
Of course, it is possible to cover all the points using only one rectangle, but this rectangle could have a very large surface area. Our goal is to find a selection of required rectangles such that the sum of their surface areas is minimal.
Input
The first line of input contains the integer
Output
You must output the required minimal sum of surface areas of the rectangles.
Samples
Input 1
Copy
2
1 1
-1 -1
Output 1
Copy
4
Input 2
Copy
3
-7 19
9 -30
25 10
Output 2
Copy
2080
Input 3
Copy
6
1 20
3 17
5 15
8 12
9 11
10 10
Output 3
Copy
760
Comments