救生员
作者:
wmh1024
,
2024-04-06 21:33:15
,
所有人可见
,
阅读 6
#include <bits/stdc++.h>
using namespace std;
const int M = 1005;
int a[M], b[M];
int ans = 0;
typedef pair<int, int> PII;
vector<PII> v;
int main() {
int N;
cin >> N;
for (int i = 0; i < N; i ++ ) {
int x, y;
cin >> x >> y;
b[x]++, b[y]--;
v.push_back({x, y});
}
for (int i = 0; i < N; i ++ ) {
int res = 0;
memcpy(a, b, sizeof(b));
int x = v[i].first, y = v[i].second;
a[x]--, a[y]++;
for (int j = 1; j < M ;j ++ ) {
a[j] += a[j - 1];
}
for (int j = 0; j < M ;j ++ ) {
// !!!
res += !!a[j];
}
ans = max(ans, res);
}
cout << ans << endl;
return 0;
}