Police Stations
Time limit1sMemory limit512 MB
Choose integer coordinates for a control center and axis-aligned cable limits L and W so every station is reachable, minimizing L+W then L.
- Level
Medium6 of 10
- Topics
- Binary search, Math, Geometry, Greedy
- Solved
- No attempts yet
Problem
There are police stations in Flatland, and the -th police station is at coordinate . The authority wants to increase cooperation among these police stations by reducing the miscommunication that often arises between them. To do this, the authority decides to build a new tower that will serve as the Communication Control Center (CCC). The CCC can only be built at where both and are integers. It does not matter whether a police station already occupies ; the CCC can be built alongside that police station.
The CCC then draws a communication cable to each police station, with some restrictions.
- Each cable serves only one police station, so serving police stations requires cables.
- A cable can only be laid parallel to the -axis or the -axis. Diagonal crossing is not allowed.
Because of a strange physics law in Flatland, each cable can have length at most in the -axis direction and at most in the -axis direction. This is why such a cable is called an cable in Flatland. For stable communication, all police stations must be connected by the same type of cable.
Recent advances in science and technology in Flatland let physicists build an cable for any and they like, at a cost. The cost becomes very expensive for larger and , so the authority must find and that satisfy their need, connecting all police stations to the CCC, while minimizing the value of .
In this problem, you must find and such that is minimized, the authority can build the CCC at where both and are integers, and all police stations can be connected to the CCC with cables. If there are multiple solutions, minimize first, and then minimize .
Input
The first line contains an integer (), the number of police stations in Flatland. Each of the next lines contains two integers (), the location of a police station.
Output
Output two integers and separated by a single space, such that is minimized, the authority can build the CCC at where both and are integers, and all police stations can be connected to the CCC with cables. If there are multiple solutions, minimize first, and then minimize .