85 lines
2.1 KiB
C++
85 lines
2.1 KiB
C++
#include <algorithm>
|
|
#include <climits>
|
|
#include <cstdio>
|
|
#include <iostream>
|
|
#include <vector>
|
|
using namespace std;
|
|
|
|
// ----- FILE IO -----
|
|
#define STDIN(filename) freopen(filename, "r", stdin)
|
|
#define STDOUT(filename) freopen(filename, "w", stdout)
|
|
#define FASTIO cin.tie(0)->sync_with_stdio(0)
|
|
#define STDIO(filename) FASTIO; string filenamee(filename); STDIN((filenamee + ".in").c_str()); STDOUT((filenamee + ".out").c_str())
|
|
#define NL '\n'
|
|
#define CM ", "
|
|
|
|
// ----- FOR LOOPS -----
|
|
#define F(i,L,R) for (int i = L; i < R; i++)
|
|
#define FE(i,L,R) for (int i = L; i <= R; i++)
|
|
#define FD(i,L,R) for (int i = L; i > R; i--)
|
|
#define FDE(i,L,R) for (int i = L; i >= R; i--)
|
|
|
|
// ----- WEZ -----
|
|
#define takeI(n) int (n); cin >> n
|
|
#define takeII(n,m) int (n),(m); cin >> n >> m
|
|
#define takeIII(n,m,k) int (n),(m),(k); cin >>(n) >> (m) >> (k)
|
|
#define whileZ takeI(T); while(T--)
|
|
//
|
|
// ----- MAX MIN -----
|
|
#define REMAX(a,b) (a)=max((a),(b))
|
|
#define REMIN(a,b) (a)=min((a),(b))
|
|
|
|
// ----- DEBUG -----
|
|
#define DBG(vari) cerr<<#vari<<" = "<<(vari)<<endl
|
|
#define printA(a,L,R) FE(i,L,R) cerr << a[i] << (i==R?'\n':' ')
|
|
#define printV(a) printA(a,0,a.size()-1)
|
|
|
|
// ----- STL DS
|
|
#define ALL(c) (c).begin(),(c).end()
|
|
|
|
int main() {
|
|
STDIO("balancing");
|
|
|
|
takeII(n, k);
|
|
vector<pair<int, int>> coords(n);
|
|
F(i,0,n) {
|
|
int x, y;
|
|
cin >> x >> y;
|
|
coords[i] = {x,y};
|
|
}
|
|
|
|
// Sort by X to easily separate below a and above a
|
|
int M = INT_MAX;
|
|
|
|
F(i,0,n) {
|
|
int a = coords[i].first+1;
|
|
F(j,0,n) {
|
|
int b = coords[j].second+1;
|
|
int first, second, third, fourth;
|
|
first = second = third = fourth = 0;
|
|
F(k,0,n) {
|
|
// Separate X by a
|
|
if (coords[k].first < a) {
|
|
// Separate Y by b
|
|
if (coords[k].second < b) {
|
|
first++;
|
|
} else {
|
|
second++;
|
|
}
|
|
} else {
|
|
// Separate Y by b
|
|
if (coords[k].second < b) {
|
|
third++;
|
|
} else {
|
|
fourth++;
|
|
}
|
|
}
|
|
}
|
|
int maxxx = max(max(max(first, second), third), fourth);
|
|
M = REMIN(M, maxxx);
|
|
}
|
|
}
|
|
|
|
cout << M;
|
|
}
|