陈祉尹  •  1个月前


include <bits/stdc++.h>

using namespace std;

define int long long

define uint unsigned long long

define resetIO(x) freopen(#x".in", "r", stdin), freopen(#x".out", "w", stdout)

define debug(fmt, ...) \

fprintf(stderr, "[%s:%d] " fmt "\n", __FILE__, __LINE__, ## __VA_ARGS__)

template inline T &read(T &x){

bool f = true; x = 0; char ch = getchar();
for(; !isdigit(ch); ch = getchar()) f ^= (ch == '-');
for(; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
return f ? x : (x = -x);

} template inline void write(T x){

if(x < 0) putchar('-'), x = -x;
if(x > 9) write(x / 10);
putchar((x % 10) ^ 48);

} const int maxn = 1e5+5; const int inf = 0x3f3f3f3f3f3f3f3f; struct node{

int l, r;
bool operator<(const node &o)const{
	return l < o.l;
}

}; int n, m1, m2, cnt1[maxn], cnt2[maxn]; node a1[maxn], a2[maxn]; set st; signed main(){

// resetIO(airport);
read(n); read(m1); read(m2);
for(int i=1; i<=m1; i++)
	read(a1[i].l), read(a1[i].r);
for(int i=1; i<=m2; i++)
	read(a2[i].l), read(a2[i].r);
st.clear();
for(int i=1; i<=m1; i++)
	st.insert(a1[i]);
for(int i=1; i<=n; i++){
	int pos = 0, c = 0;
	while(true){
		auto it = st.lower_bound(node{pos, 0});
		if(it == st.end()) break;
		pos = it->r;
		st.erase(it); ++c;
	}
	cnt1[i] = cnt1[i - 1] + c;
}
st.clear();
for(int i=1; i<=m2; i++)
	st.insert(a2[i]);
for(int i=1; i<=n; i++){
	int pos = 0, c = 0;
	while(true){
		auto it = st.lower_bound(node{pos, 0});
		if(it == st.end()) break;
		pos = it->r;
		st.erase(it); ++c;
	}
	cnt2[i] = cnt2[i - 1] + c;
}
int ans = 0;
for(int i=0; i<=n; i++)
	ans = max(ans, cnt1[i] + cnt2[n - i]);
write(ans); putchar('\n');
return 0;

}


评论:

请先登录,才能进行评论