#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#define ll long long
using namespace std;
inline int read(){
int x=0,o=1;char ch=getchar();
while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
if(ch=='-')o=-1,ch=getchar();
while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
return x*o;
}
const int N=2e5+5;
struct node{
int x,y;
bool operator <(const node &p)const{
return x==p.x?y<p.y:x<p.x;
}
}a[N],b[N<<1];
multiset<int>s;
int main(){
int n=read(),m=read(),ans=0;
for(int i=1;i<=n;++i)a[i].x=read(),a[i].y=read();
for(int i=1;i<=m;++i)b[i].x=read(),b[i].y=read();
sort(a+1,a+n+1);sort(b+1,b+m+1);
for(int i=1,j=1;i<=m;++i){
while(j<=n&&a[j].x<=b[i].x)s.insert(a[j].y),++j;
while(s.size()&&*s.begin()<b[i].x)s.erase(s.begin());
while(s.size()>b[i].y)s.erase(--s.end()),++ans;
}
printf("%d\n",n-ans);
return 0;
}
原文:https://www.cnblogs.com/PPXppx/p/11743891.html