Smallest Square 2
Time limit2sMemory limit512 MB
Given N lattice points, choose an axis-aligned square with lattice corners containing at least K points strictly inside and minimize its area.
- Level
Medium7 of 10
- Topics
- Binary search, Sorting, Two pointers, Prefix sum
- Solved
- No attempts yet
Problem
There are points on the coordinate plane. Every point has integer coordinates.
Consider the squares that satisfy all three conditions below.
- All four corners have integer coordinates.
- Every side is parallel to a coordinate axis.
- At least points lie strictly inside the square. A point on the boundary does not count as being inside.
Write a program that finds the smallest area among these squares.
Input
The first line contains the number of points and an integer . (, )
Each of the next lines contains the coordinates and of one point, separated by a space. ()
No point is given more than once.
Output
Print the smallest area among the squares that satisfy the conditions.