This documentation is automatically generated by online-judge-tools/verification-helper
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/5/DSL_5_B"
#include "../../../src/template/template.hpp"
#include "../../../src/data_structure/cumulative_sum_2d.hpp"
int main(void) {
int n;
cin >> n;
CumulativeSum2D<int> cum(1001, 1001);
rep(i, 0, n) {
int xl, yl, xr, yr;
cin >> xl >> yl >> xr >> yr;
cum.add(xl, yl, 1);
cum.add(xl, yr, -1);
cum.add(xr, yl, -1);
cum.add(xr, yr, 1);
}
cum.build();
int ans = 0;
rep(i, 0, 1001) {
rep(j, 0, 1001) {
ans = max(ans, cum.sum(0, 0, i, j));
}
}
cout << ans << '\n';
}
#line 1 "verify/aizu_online_judge/dsl/the_maximum_number_of_overlaps.test.cpp"
#define PROBLEM "https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/5/DSL_5_B"
#line 2 "src/template/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<long long, long long>;
#define rep(i, a, b) for(long long i = (a); i < (b); ++i)
#define rrep(i, a, b) for(long long i = (a); i >= (b); --i)
constexpr long long inf = 4e18;
struct SetupIO {
SetupIO() {
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed << setprecision(30);
}
} setup_io;
#line 3 "src/data_structure/cumulative_sum_2d.hpp"
template <typename T>
struct CumulativeSum2D {
CumulativeSum2D(const int H, const int W)
: h(H), w(W), data(H + 1, vector<T>(W + 1, 0)) {}
void add(const int i, const int j, const T& x) {
assert(0 <= i and i < h);
assert(0 <= j and j < w);
data[i + 1][j + 1] += x;
}
void build() {
for(int i = 1; i < (int)data.size(); ++i) {
for(int j = 1; j < (int)data[i].size(); ++j) {
data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1];
}
}
}
T sum(const int li, const int lj, const int ri, const int rj) const {
assert(0 <= li and li <= ri and ri <= h);
assert(0 <= lj and lj <= rj and rj <= w);
return data[ri][rj] - data[li][rj] - data[ri][lj] + data[li][lj];
}
T get(const int i, const int j) const {
assert(0 <= i and i < h);
assert(0 <= j and j < w);
return data[i + 1][j + 1] - data[i][j + 1] - data[i + 1][j] + data[i][j];
}
private:
int h, w;
vector<vector<T>> data;
};
#line 4 "verify/aizu_online_judge/dsl/the_maximum_number_of_overlaps.test.cpp"
int main(void) {
int n;
cin >> n;
CumulativeSum2D<int> cum(1001, 1001);
rep(i, 0, n) {
int xl, yl, xr, yr;
cin >> xl >> yl >> xr >> yr;
cum.add(xl, yl, 1);
cum.add(xl, yr, -1);
cum.add(xr, yl, -1);
cum.add(xr, yr, 1);
}
cum.build();
int ans = 0;
rep(i, 0, 1001) {
rep(j, 0, 1001) {
ans = max(ans, cum.sum(0, 0, i, j));
}
}
cout << ans << '\n';
}