#P15602. [ICPC 2020 Jakarta R] Police Stations
[ICPC 2020 Jakarta R] Police Stations
题目描述
There are police stations in Flatland and the police station is located at a coordinate . The authority plans to increase the synergy between these police stations by reducing any miscommunication that often arises among them. To do this, the authority decides to build a new tower that will serve as the Communication Control Center (CCC). Note that the CCC can only be built at where and are integers. It does not matter whether there is already a police station at ; CCC can be built along with that police station.
CCC then will draw a communication cable to each of the police stations with some restrictions.
- Each cable only serves a police station, thus, to serve police stations, they will need cables.
- The cable can only be laid out parallel to -axis and -axis; no diagonal crossing is allowed.
Due to some weird physics law in Flatland, each cable can only have a length of at most in -axis direction and a length of at most in -axis direction; this is the reason why this type of cable is known as cable in Flatland. To have stable communication, all police stations should be connected by the same type of cable.
Recent science and technology advancements in Flatland allows the physicists to build an cable for any and they like, with a cost. As the cost becomes quite expensive for larger and , the authority needs to figure out and that can satisfy their need, i.e. to connect all police stations with CCC, while minimizing the value of .
Your task in this problem is to find and such that the value of is minimum and the authority can build CCC at where both and are integers while all police stations can be connected to the CCC with cables. If there are multiple solutions, minimize first, and then minimize .
输入格式
Input begins with a line containing an integer: () representing the number of police stations in Flatland. The next lines each contains two integers: () representing the location of each police station.
输出格式
Output in a line two integers (separated by a single space), and , respectively, such that the value of is minimum and the authority can build CCC at where both and are integers while all police stations can be connected to the CCC with cables. If there are multiple solutions, minimize first, and then minimize .
5
20 90
-10 40
90 20
50 -30
50 70
50 60
提示
Explanation for the sample input/output #1
The optimal decision that can be made by the authority is to build the CCC at and prepare for cables to connect all police stations to the CCC.
Explanation for the sample input/output #2
To have a minimum , the CCC must be built at or . Either way, they will need cables to connect both police stations to the CCC.
Explanation for the sample input/output #3
The optimal decision that can be made by the authority is to build the CCC at and prepare for cables to connect all police stations to the CCC.