我们发现, 对于每个ti, 答案为
不会做先排序, 将li<=ti的ri插入set, 然后lower_bound 就可以了
#include<bits/stdc++.h>
#define N 200050
using namespace std;
int n,m;
struct Node{
int l,r;
friend bool operator < (const Node &a, const Node &b){
return a.l<b.l;
}
}A[N];
int t[N],siz,ans;
multiset<int> S;
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++){
scanf("%d%d",&A[i].l,&A[i].r);
} sort(A+1,A+n+1);
for(int i=1;i<=m;i++) scanf("%d",&t[i]);
sort(t+1,t+m+1);
int pos = 1;
for(int i=1;i<=m;i++){
while(pos<=n && A[pos].l<=t[i]) S.insert(A[pos].r), pos++;
multiset<int>::iterator it = S.lower_bound(t[i]);
if(it==S.end()) continue;
ans ++; S.erase(it);
} printf("%d",ans); return 0;
}