#P3138. Balanced Cow Fencing

    ID: 16396 Type: Default 1000ms 256MiB

Balanced Cow Fencing

Balanced Cow Fencing

Farmer John has N cows located at distinct points on an infinite 2D plane. The coordinates of the ith cow are \( (x_i,y_i) \), where each \( x_i \) and \( y_i \) is an odd positive integer no more than \(10^6\). FJ plans to build one vertical fence with equation \( x=a \) and one horizontal fence with equation \( y=b \) such that both \( a \) and \( b \) are even. These two fences intersect at \( (a,b) \) and partition the plane into four regions.

Let \( M \) be the maximum number of cows in any one of the four regions. Help FJ choose \( a \) and \( b \) such that \( M \) is minimized. Output this minimum possible value of \( M \).

Note: Since the cows lie on odd coordinates and the fences must be placed on even coordinates, no fence will pass directly through a cow.

inputFormat

The first line contains one integer \( N \) (\(1 \le N \le 1000\)), the number of cows. Each of the next \( N \) lines contains two integers \( x_i \) and \( y_i \) (each odd and at most \(10^6\)), representing the coordinates of a cow.

outputFormat

Output the minimum possible value of \( M \), where \( M \) is the maximum number of cows in any quadrant after partitioning.

sample

4
1 1
3 1
1 3
3 3
1