#K1971. Minimum Road Length

    ID: 24633 Type: Default 1000ms 256MiB

Minimum Road Length

Minimum Road Length

You are given n cities, each with coordinates on a 2D plane. Your task is to compute the minimum possible length of a road that can either be placed horizontally or vertically such that the road passes through all given cities.

The road can run either horizontally or vertically, and its effective length is determined by the maximum range among the x-coordinates and the y-coordinates. In other words, if the cities have x-coordinates ranging from \(x_{min}\) to \(x_{max}\) and y-coordinates from \(y_{min}\) to \(y_{max}\), then the minimum road length required is given by:

\[ \text{min\_road\_length} = \max(x_{max} - x_{min},\; y_{max} - y_{min}) \]

This problem tests basic implementation and the understanding that a single straight line (either horizontal or vertical) best covers the spread of points using the maximum span.

inputFormat

The first line contains an integer n representing the number of cities. Each of the following n lines contains two space-separated integers x and y, which are the coordinates of a city.

outputFormat

Output a single integer representing the minimum possible length of the road that can run horizontally or vertically and pass through all the cities.

## sample
3
1 1
2 3
3 2
2