## COCI '17 Contest 6 #4 Cover

View as PDF

Points: 15
Time limit: 1.0s
Memory limit: 64M

Problem type

You are given points in the coordinate system. They need to be covered with one or more rectangles, such that the following conditions are met:

• 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 Specification

The first line of input contains the integer , the number of points. Each of the following lines contains two integers and , the coordinates of each point.

#### Output Specification

You must output the required minimal sum of surface areas of the rectangles.

#### Scoring

In test cases worth of total points, it will hold .

#### Sample Input 1

2
1 1
-1 -1

#### Sample Output 1

4

#### Explanation for Sample Output 1

We choose the rectangle whose opposite angles are the given points, since it meets the conditions from the task.

#### Sample Input 2

3
-7 19
9 -30
25 10

#### Sample Output 2

2080

#### Explanation for Sample Output 2

We choose two rectangles with their centers in the origin. The first is of dimensions and covers point . The second is of dimensions and covers the first two points. If we wanted to cover all the points using one rectangle, it would be of dimensions .

#### Sample Input 3

6
1 20
3 17
5 15
8 12
9 11
10 10

#### Sample Output 3

760