#P3138. [USACO16FEB] Load Balancing S

    ID: 2177 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>2016线段树USACO枚举,暴力前缀和

[USACO16FEB] Load Balancing S

Description

Farmer John has NN cows (1N10001 \leq N \leq 1000) scattered across his farm. The farm is an infinite 2D plane, and the ii-th cow is located at (xi,yi)(x_i, y_i) (it is guaranteed that xix_i and yiy_i are positive odd integers, and xi,yi106x_i, y_i \leq 10^6). No two cows are at the same position.

FJ wants to build a vertical fence with equation x=ax = a, and a horizontal fence with equation y=by = b. To ensure the fences do not pass through any cow, both aa and bb must be even. It is easy to see that these two fences intersect at (a,b)(a, b), partitioning the farm into four regions.

FJ wants the number 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 possible value of MM.

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

Hint

Translated by ChatGPT 5