#K15341. Taco Perimeter

    ID: 24335 Type: Default 1000ms 256MiB

Taco Perimeter

Taco Perimeter

You are given a set of points in the 2D plane. Your task is to compute the perimeter of the smallest axis-aligned rectangle that can enclose all of the points. The rectangle's sides must be parallel to the coordinate axes.

Formally, let \(\{(x_i, y_i)\}_{i=1}^{n}\) be the set of points. Define \(x_{min}=\min_{i} x_i\), \(x_{max}=\max_{i} x_i\), \(y_{min}=\min_{i} y_i\), and \(y_{max}=\max_{i} y_i\). The required rectangle has width \(w=x_{max}-x_{min}\) and height \(h=y_{max}-y_{min}\), and its perimeter is given by \[ P=2\times (w+h)\,. \]

If there is only one point (or none), it is considered that the perimeter is 0.

inputFormat

The input is read from standard input (stdin). The first line contains an integer (n) representing the number of points. Each of the following (n) lines contains two space-separated integers, (x) and (y), representing the coordinates of a point.

outputFormat

Output a single integer to standard output (stdout): the perimeter of the smallest axis-aligned rectangle that encloses all of the points. If the number of points is less than 2, output 0.## sample

1
0 0
0