Load Balancing
InterviewTime limit1sMemory limit512 MB
John places one vertical and one horizontal fence to minimize the largest cow count in the four regions.
- Level
Medium5 of 10
- Topics
- Brute force, Sorting
- Solved
- No attempts yet
Problem
Farmer John's cows stand at distinct positions on his two dimensional farm (). Every and is a positive odd integer of size at most .
To split the farm, John builds a very long fence running north to south along the line . The value is an even integer, so the fence never passes through the position of a cow. He also builds a very long fence running east to west along the line , where is an even integer as well. The two fences meet at the point and cut the farm into four regions.
Let be the number of cows in the region that holds the most cows. John wants to pick and so that is as small as possible. Find the smallest value of .
Input
The first line contains the number of cows . Each of the next lines contains two integers and separated by a space, the position of one cow.
Output
Print on one line the smallest value of that John can reach by placing the two fences optimally.