20pts玄关
查看原帖
20pts玄关
1109463
godess楼主2024/10/17 13:49
#include<cstdio>
#include<algorithm>
#include<queue>
#include<iterator>
#include<utility>
using namespace std;
const int M = 100003;
struct abc {
	int s, f;
}a[M], b[M];
int cnt, c[M], d[M], sd[M], sc[M];
vector<pair<int, int>> t, r;
bool cmp(abc x, abc y) { return x.s < y.s; }
int main() {
	//freopen("airport3.in", "r", stdin);
	int n, m1, m2;
	scanf("%d%d%d", &n, &m1, &m2);
	for (int i = 1; i <= m1; i++) {
		scanf("%d%d", &a[i].s, &a[i].f);
	}
	for (int i = 1; i <= m2; i++) {
		scanf("%d%d", &b[i].s, &b[i].f);
	}
	sort(a + 1, a + m1 + 1, cmp);
	sort(b + 1, b + m2 + 1, cmp);
	for (int i = 1; i <= m1; i++) {
		pair<int, int> p;
		auto ind = lower_bound(t.begin(), t.end(), make_pair(a[i].s, 0));
		auto id = lower_bound(t.begin(), t.end(), make_pair(a[i].f, 0));
		if (ind == t.begin()) p = make_pair(a[i].f, ++cnt);
		else p = make_pair(a[i].f, (*(--ind)) .second);
		c[p.second]++;
		t.insert(id,p);
	}
	cnt = 0;
	for (int i = 1; i <= m2; i++) {
		pair<int, int> p;
		auto ind = lower_bound(r.begin(), r.end(), make_pair(b[i].s, 0));
		auto id = lower_bound(r.begin(), r.end(), make_pair(b[i].s, 0));
		if (ind == r.begin()) p = make_pair(b[i].f, ++cnt);
		else p = make_pair(b[i].f, (*(--ind)).second);
		d[p.second]++;
		r.insert(id, p);
	}
	for (int i = 1; i <= n; i++) {
		sd[i] = sd[i - 1] + d[i];
		sc[i] = sc[i - 1] + c[i];
	}
	//for (auto i : t) printf("%d\n", i.second);
	//for (auto i : r) printf("%d\n", i.second);
	int ans = 0;
	for (int i = 0; i <= n; i++) {
		ans = max(ans, sd[i] + sc[n - i]);
	}
	printf("%d", ans);
	return 0;
}
2024/10/17 13:49
加载中...