Cricket Field
Time limit2sMemory limit128 MB
Given up to 100 tree points in a W by H rectangle, find the largest axis-aligned square inside the park with no tree strictly inside it.
- Level
Medium6 of 10
- Topics
- Geometry, Brute force, Sorting
- Solved
- No attempts yet
Problem
A greedy King orders his Architect to build a square cricket field inside the royal park. The King refuses to let a single tree be cut down or newly planted, yet still demands the largest possible field. Help the Architect find it.
The park is a rectangle on flat ground whose sides are aligned with the coordinate axes, and the cricket field is an axis-aligned square. In the Architect's coordinate system the park's south-western corner is at and its north-eastern corner is at , where and are the park's width and height in feet.
Tree diameters may be ignored, so each tree is a single point. No tree may lie strictly inside the field, but a tree may lie on the field's border. The field must lie entirely within the park, though it may touch the park's border.
Find the maximum possible side length of the cricket field.
Input
The first line contains three integers , , and (, ): the number of trees, and the park's width and height in feet.
Each of the next lines contains two integers and (, ), the coordinates of the -th tree. All trees are at distinct coordinates.
Output
Print a single integer : the maximum possible side length of a square cricket field that fits inside the park and has no tree strictly in its interior.