~~ ~~

## Topic analysis

## Algorithm design

** Orderly**

## Example code

` `#include <cstdio>
#include <cstring>
#include <algorithm>
const int N = 1100;
int n;
struct cd {
int x, y;
} c[N];
bool cmp(cd a, cd b) {
if (a.x == b.x) return a.y < b.y;
return a.x < b.x;
}
int *d[N];
bool cmp_d(int *a, int *b) {
return *a < *b;
}
int t[N], b[N]; // 水平轴切开的上下两部分，top bottom
void change(int t[], int k, int x) {
while (k <= n) {
t[k] += x;
k += k & (-k);
}
}
int sum(int t[], int k) {
int x = 0;
while (k > 0) {
x += t[k];
k -= k & (-k);
}
return x;
}
int main() {
// freopen("input.txt", "r", stdin);
freopen("balancing.in", "r", stdin);
freopen("balancing.out", "w", stdout);
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d%d", &c[i].x, &c[i].y);
// 对x进行排序，便于下方移动水平轴
std::sort(c + 1, c + n + 1, cmp);
// for (int i = 1; i <= n; i++) printf("%d %d\n", c[i].x, c[i].y); printf("\n");
// 对y进行离散化，便于下方移 动垂直轴
for (int i = 1; i <= n; i++) d[i] = &c[i].y;
std::sort(d + 1, d + n + 1, cmp_d);
int last = 0, count = 0;
for (int i = 1; i <= n; i++) {
if (*d[i] != last) {
count++;
last = *d[i];
}
*d[i] = count;
}
// for (int i = 1; i <= n; i++) printf("%d %d\n", c[i].x, c[i].y); printf("\n");
// 移动水平轴，并且枚举垂直轴
memset(t, 0, sizeof t);
memset(b, 0, sizeof b);
for (int i = 1; i <= n; i++) change(b, c[i].y, 1); // 先填充水平轴下方的内容
int ans = 0x7fffffff;
int i = 1;
while (i <= n) {
int row = c[i].x;
// 从水平轴下方删除，并且添加到水平轴上方
while (i <= n && c[i].x == row) {
change(t, c[i].y, 1);
change(b, c[i].y, -1);
i++;
}
for (int j = 1; j <= n; j++) {
int tmp, stage_ans = 0;
tmp = sum(t, j); // 上左
if (tmp > stage_ans) stage_ans = tmp;
tmp = sum (T, n) - TMP; / / upper right
if (TMP > stage_ans) stage_ans = TMP;
tmp = stage_ans; (/) (/ / lower left ((>)) = =;; = = (()); - / / lower right ((>)) = =;; ((<)) = =; (0);