#P6172. [USACO16FEB] Load Balancing P

[USACO16FEB] Load Balancing P

Description

Farmer John has NN cows (1N1051 \leq N \leq 10^5) scattered across the farm. The farm is an infinitely large 2D plane. The position of the ii-th cow is (xi,yi)(x_i, y_i) (it is guaranteed that both xix_i and yiy_i are positive odd numbers, and xi,yi106x_i, y_i \leq 10^6), and no two cows are at the same location.

FJ wants to build a vertical fence with equation x=ax = a, and also a horizontal fence with equation y=by = b. To prevent the fences from passing through any cows, both aa and bb must be even numbers. It is easy to see that these two fences intersect at (a,b)(a, b), dividing the farm into four regions.

FJ wants the numbers of cows in the four regions to be as balanced as possible, avoiding the situation where one region has many cows while another has few. Let MM be the maximum number of cows among the four regions. Please help FJ find the minimum possible value of MM.

Input Format

The first line contains an integer NN.

The next NN lines each contain two integers xi,yix_i, y_i, describing the position of the ii-th cow.

Output Format

Output the minimum value of MM.

7
7 3
5 5
7 13
3 1
11 7
5 3
9 1
2

Hint

Translated by ChatGPT 5