아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Location, Location, Location

시간 제한3초메모리 제한1024 MB

요약
주어진 n개 점까지의 맨해튼 거리 합을 최소로 하는 점을 찾고, 답이 여러 개면 x와 y가 작은 쪽을 출력한다.
난이도

보통10점 중 4점

유형
수학, 정렬, 그리디
정답자
아직 제출이 없습니다

문제

The concept of "location, location, location" is a common phrase used in real estate and business to emphasize the importance of the physical location of a property or business. In real estate, it suggests that the desirability and value of a property are heavily influenced by its location, often more so than by the property's features or condition. In business, it highlights that the success of a retail store or commercial establishment can be significantly impacted by its geographical location.

In recent years, people tend to buy electric vehicles, but the buyers soon find it is hard to install charging piles in their apartments or houses. Building a charging station can be a good idea to make a lot of money. Your boss, Lena, ask you to find a good location for establishing her charge station to serve the electric vehicle owners.

In recent times, there has been a growing trend towards the adoption of electric vehicles (EVs). However, many EV owners face the challenge of installing charging infrastructure in their apartments or houses. Establishing a charging station presents a lucrative opportunity in response to this demand. Your boss, Lena, has tasked you with identifying an optimal location for building a charging station to cater to the needs of electric vehicle owners.

You are given a list of nn locations represented as (x,y)(x,y) coordinates in a 2D plane. For each location, there is an apartment or a house without any charging infrastructure. Your task is to build a charging station at the location that is closest to all nn locations on the list. In this problem, distance is measured using the Manhattan distance metric. The Manhattan distance between two points (x_1,y_1)(x\_1,y\_1) and (x_2,y_2)(x\_2,y\_2) is defined as ∣x_1−x_2∣+∣y_1−y_2∣|x\_1-x\_2|+|y\_1-y\_2|. Your goal is to find a location (x,y)(x,y) such that the sum of the Manhattan distances from that location to all nn locations on the list is minimized.

입력

The first line contains a positive integer nn indicating the number of locations. The ii-th of the nn following lines contains two integers x_ix\_i and y_iy\_i. The coordinates of the ii-th location is (x_i,y_i)(x\_i, y\_i).

출력

Print the location (x,y)(x,y) minimizing the sum of Manhattan distance from (x,y)(x,y) to all nn locations on the list. If there are multiple solutions, output the one minimizing xx. If there still multiple solutions, output the one minimizing yy.

제한

  • 1≤n≤1000001≤n≤100000
  • −100000≤x_i≤100000-100000≤x\_i≤100000 for 1≤i≤n1≤i≤n.
  • −100000≤y_i≤100000-100000≤y\_i≤100000 for 1≤i≤n1≤i≤n.

예제2

  1. 예제 1

    입력
    4
    3 1
    0 2
    2 3
    1 0
    
    예상 출력
    1 1
    
  2. 예제 2

    입력
    2
    0 0
    2 2
    
    예상 출력
    0 0