#P15602. [ICPC 2020 Jakarta R] Police Stations

[ICPC 2020 Jakarta R] Police Stations

题目描述

There are NN police stations in Flatland and the ithi^{th} police station is located at a coordinate (xi,yi)(x_i, y_i). 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 (x,y)(x, y) where xx and yy are integers. It does not matter whether there is already a police station at (x,y)(x, y); 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 NN police stations, they will need NN cables.
  • The cable can only be laid out parallel to xx-axis and yy-axis; no diagonal crossing is allowed.

Due to some weird physics law in Flatland, each cable can only have a length of at most LL in xx-axis direction and a length of at most WW in yy-axis direction; this is the reason why this type of cable is known as (L,W)(L, W) 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 (L,W)(L, W) cable for any LL and WW they like, with a cost. As the cost becomes quite expensive for larger LL and WW, the authority needs to figure out LL and WW that can satisfy their need, i.e. to connect all police stations with CCC, while minimizing the value of L+WL + W.

Your task in this problem is to find LL and WW such that the value of L+WL + W is minimum and the authority can build CCC at (x,y)(x, y) where both xx and yy are integers while all police stations can be connected to the CCC with (L,W)(L, W) cables. If there are multiple solutions, minimize LL first, and then minimize WW.

输入格式

Input begins with a line containing an integer: NN (1N1000001 \leq N \leq 100\,000) representing the number of police stations in Flatland. The next NN lines each contains two integers: xi yix_i\ y_i (106xi,yi106-10^6 \leq x_i, y_i \leq 10^6) representing the location of each police station.

输出格式

Output in a line two integers (separated by a single space), LL and WW, respectively, such that the value of L+WL + W is minimum and the authority can build CCC at (x,y)(x, y) where both xx and yy are integers while all police stations can be connected to the CCC with (L,W)(L, W) cables. If there are multiple solutions, minimize LL first, and then minimize WW.

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 (40,30)(40, 30) and prepare for 50,60\langle 50, 60 \rangle cables to connect all police stations to the CCC.

Explanation for the sample input/output #2

To have a minimum L+WL + W, the CCC must be built at (121,744)(121, 744) or (121,745)(121, 745). Either way, they will need 1,5\langle 1, 5 \rangle 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 (31,30)(31, 30) and prepare for 61,50\langle 61, 50 \rangle cables to connect all police stations to the CCC.