农夫约翰的 N 头奶牛分别位于其二维农场的不同位置,(x1,y1)…(xN,yN),保证 xi,yi 均为正奇数,且不超过 B。
约翰希望构建一个南北方向的无限长的栅栏来划分他的农场,栅栏可用 x=a 来表示,a 必须为偶数。
此外,他还希望构建一个东西方向的无限长的栅栏,该栅栏可用 y=b 来表示,b 必须为偶数。
这两个栅栏在点 (a,b) 处相交,将田地划分为了四个区域。
约翰希望通过合理的选择 a,b,使得四个区域的奶牛数量尽可能“均衡”,不会存在某个区域包含太多的奶牛。
用 M 表示四个区域中包含奶牛数量最多的区域所包含的奶牛数量。
约翰希望 M 尽可能小,请你计算,M 的最小可能值。
输入格式
第一行包含整数 N 和 B。
接下来 N 行,每行包含两个整数 x,y,表示其中一头奶牛的位置的横纵坐标。
输出格式
输出 M 的最小可能值。
数据范围
1≤N≤100,
1≤B≤106
FJ wants to choose a and b so that the cows appearing in the four resulting regions are reasonably "balanced", with no region containing too many cows. Letting M be the maximum number of cows appearing in one of the four regions, FJ wants to make M as small as possible. Please help him determine this smallest possible value for M.
For the first five test cases, B is guaranteed to be at most 100. In all test cases, B is guaranteed to be at most 1,000,000.
7 10 7 3 5 5 9 7 3 1 7 7 5 3 9 1
2
Problem credits: Brian Dean