| 记录编号 | 589280 | 评测结果 | AAAAAAAAAA | 
    
        | 题目名称 | 3131.梦境 | 最终得分 | 100 | 
    
        | 用户昵称 |  蜀山鸭梨大 | 是否通过 | 通过 | 
    
        | 代码语言 | C++ | 运行时间 | 0.512 s | 
    
        | 提交时间 | 2024-07-04 16:42:06 | 内存使用 | 4.27 MiB | 
    
    
    
    		显示代码纯文本
		
		#include<bits/stdc++.h>
using namespace std;
int n,m,t[200005],e,sum;
struct node{
	int l,r;
}a[200005];
priority_queue<int,vector<int>,greater<int> > q;
bool cmp(node x,node y){
	if(x.l==y.l) return x.r<y.r;
	return x.l<y.l;
}
int main(){
	freopen("dream.in","r",stdin);
	freopen("dream.out","w",stdout);
	cin>>n>>m;
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i].l,&a[i].r);
	for(int i=1;i<=m;i++) scanf("%d",&t[i]);
	sort(a+1,a+1+n,cmp);
	sort(t+1,t+1+m);
	for(int i=1;i<=m;i++){
		while(a[e].l<=t[i]&&e<=n){
			q.push(a[e].r);
			e++;
		}
		while(q.size()&&q.top()<t[i]){
			q.pop();
		}
		if(q.size()&&q.top()>=t[i]){
			q.pop();
			sum++;
		}
	} 
	printf("%d",sum);
	return 0;
}