#P15928. [TOPC 2023] Location, Location, Location
[TOPC 2023] Location, Location, Location
题目描述
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 locations represented as 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 locations on the list. In this problem, distance is measured using the Manhattan distance metric. The Manhattan distance between two points and is defined as . Your goal is to find a location such that the sum of the Manhattan distances from that location to all locations on the list is minimized.
输入格式
The first line contains a positive integer indicating the number of locations. The -th of the following lines contains two integers and . The coordinates of the -th location is .
输出格式
Print the location minimizing the sum of Manhattan distance from to all locations on the list. If there are multiple solutions, output the one minimizing . If there still multiple solutions, output the one minimizing .
4
3 1
0 2
2 3
1 0
1 1
2
0 0
2 2
0 0
提示
- for .
- for .