Cover All Points with Three Squares
Time limit2sMemory limit64 MB
Find the smallest integer side length d so that three axis-aligned d×d squares can cover all N given points.
- Level
Hard8 of 10
- Topics
- Binary search, Greedy, Geometry, Sorting
- Solved
- No attempts yet
Problem
Yesterday was real fun.
This morning you wake up and notice that something is just not right. It is not merely a headache; something keeps nagging at you, yet you cannot pin down exactly what it is. You pace around your room, enjoying the sunlight streaming through the open window, and through the holes in the roof... Wait. There were no holes in the roof until today. Definitely.
Suppressing the urge to call your friends and find out where the holes came from, you decide to fix the roof first, in a modern way.
You have decided to nail down 3 equal square boards, with sides parallel to the sides of your (of course, square) roof, to close all the holes, and you wonder what the minimum board size must be.
You are given distinct points on the Cartesian plane. Find the minimum such that three axis-parallel squares (they may overlap) can cover all the points (a point lying on the border counts as covered).
Because all coordinates are integers, the answer is always an integer. Print as an integer.
Input
The first line contains the number of points ().
Each of the next lines contains two integers and , the coordinates of the -th hole (). No two points coincide.
Output
Print, on a single line, the minimum integer that allows all the points to be covered.