Square Stamping

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

요약
y좌표가 -9999, 0, 9999인 점들이 주어질 때, 한 변의 길이가 10000인 축에 평행한 정사각형의 최소 개수로 모든 점을 덮는 문제입니다.
난이도

보통10점 중 7점

유형
그리디, 정렬, 구간, 동적 계획법
정답자
아직 제출이 없습니다

문제

In the plane, there are nn points whose yy-coordinates are either −9999-9999, 00, or 99999999. Let PP be the set of these nn points. Your task is to enclose all the points in PP by a minimum number of congruent axis-parallel squares of side length 10,00010\\,000. As a subset of the plane, each such square consists of all points inside and on the boundary.

입력

Your program is to read from standard input. The input starts with a line consisting of a single integer nn (1≤n≤300,0001 ≤ n ≤ 300\\,000), representing the number of input points in PP. In each of the following nn lines, there are two integers xx and yy, representing the xx- and yy-coordinates of a point in PP, respectively, such that it holds that −109≤x≤109-10^9 ≤ x ≤ 10^9 and y∈−9999,0,9999y \in \\{-9999, 0, 9999\\}. You may assume that all the nn input points are distinct.

출력

Your program is to write to standard output. Print exactly one line. The line should consist of a single integer that represents the minimum possible number tt such that there exist tt axis-parallel squares of side length 10,00010\\,000 whose union encloses all the input points in PP.

예제3

  1. 예제 1

    입력
    5
    0 9999
    0 0
    0 -9999
    200 0
    10000 9999
    
    예상 출력
    2
    
  2. 예제 2

    입력
    5
    10 -9999
    0 0
    3 9999
    9000 -9999
    10003 9999
    
    예상 출력
    2
    
  3. 예제 3

    입력
    6
    10 -9999
    0 0
    3 9999
    9000 -9999
    10003 -9999
    10003 9999
    
    예상 출력
    3