Two Rings

시간 제한2초메모리 제한2048 MB

요약
n개의 점을 모두 포함하면서 두 직사각형 고리의 너비 중 큰 값이 최소가 되도록 겹치지 않는 두 고리를 찾는다.
난이도

어려움10점 중 9점

유형
기하, 이분 탐색, 그리디
정답자
아직 제출이 없습니다

문제

As a planar shape, a ring can be described as the area between two concentric circles. This concept can of course be generalized to any possible shapes. For example, one might define rectangular rings to be the area between two rectangles. A precise definition of rectangular rings is as follows: Here, any rectangles we discuss is assumed to be axis-aligned, so the four sides of a rectangle are horizontal or vertical, and are distinguished as the left, right, top, and bottom sides. Any vertical or horizontal segment is also considered a rectangle with empty interior. A rectangular ring is the closed area between two rectangles RR and R′R', including the boundary, such that the following conditions are satisfied:

  1. R′R' is contained in RR, including the boundary of RR.
  2. The following four values are equal: the distance between the top side of RR and the top side of R′R', the distance between the left side of RR and the left side of R′R', the distance between the bottom side of RR and the bottom side of R′R', and the distance between the right side of RR and the right side of R′R'.

The distance described in the second condition is called the width of the rectangular ring defined by two rectangles RR and R′R'. The figure below illustrates three rectangular rings of width ww defined by two rectangles RR and R′R'. Note that the first and third ones show two extreme and degenerate cases: R′=RR' = R (thus, w=0w = 0 and the rectangular ring is the boundary of R′=RR' = R) and R′R' is a line segment (thus, RR is the rectangular ring).

Given a finite set PP of points in the plane, write a program that finds two non-penetrating rectangular rings A_1A\_1 and A_2A\_2 such that P⊂A_1∪A_2P \subset A\_1 \cup A\_2 and the larger of their widths is minimized. Two rectangular rings are called non-penetrating if one’s boundary neither intersects the other’s interior nor crosses the other’s boundary. Note that two non-penetrating rectangular rings still may touch in their boundaries in such a way that every point in the intersection between their boundaries lies in the intersection between two parallel sides of their defining rectangles or a corner.

The above figure shows (a) an example set PP of 2222 points and (b) an optimal pair of two non-penetrating rectangular rings containing PP that minimizes the larger value of their widths.

입력

Your program is to read from standard input. The input starts with a line containing an integer, nn (1≤n≤300,0001 ≤ n ≤300\\,000), where nn is the number of input points in PP. In each of the following nn lines, there are two integers between −109-10^9 and 10910^9, separated by a space, that describe the coordinates of a point in PP. You may assume that no two input points are identical.

출력

Your program is to write to standard output. Print exactly one line. The line should contain an integer that describes the minimum possible value for the larger width of two non-penetrating rectangular rings that include all points of PP.

예제2

  1. 예제 1

    입력
    13
    0 1
    1 2
    0 5
    4 6
    5 0
    6 2
    8 3
    11 1
    12 -1
    13 2
    12 4
    10 3
    3 4
    
    예상 출력
    1
    
  2. 예제 2

    입력
    13
    0 1
    1 2
    0 5
    4 6
    5 0
    6 2
    8 3
    11 -2
    12 -4
    13 -1
    12 1
    10 0
    3 4
    
    예상 출력
    2