记录编号 584643 评测结果 AAAAAAAAAA
题目名称 梦境 最终得分 100
用户昵称 Gravatar┭┮﹏┭┮ 是否通过 通过
代码语言 C++ 运行时间 0.411 s
提交时间 2023-11-14 14:57:00 内存使用 2.41 MiB
显示代码纯文本
#include <bits/stdc++.h> 
using namespace std;
const int N = 2e5+10;
int n,m;
int b[N];
struct made{
    int l,r;
    bool operator <(const made x)const{
        if(l == x.l)return r < x.r;
        else return l < x.l;
    }
}a[N];
int main(){
    freopen("dream.in","r",stdin);
    freopen("dream.out","w",stdout);
    scanf("%d%d",&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",&b[i]);
    sort(a+1,a+1+n);
    sort(b+1,b+1+m);
    int j = 1,ans = 0;
    priority_queue<int,vector<int>,greater<int> >q;
    for(int i = 1;i <= m;i++){
        while(a[j].l <= b[i] && j <= n)q.push(a[j].r),j++;
        while(!q.empty()){
            if(q.top() < b[i])q.pop();
            else break;
        }
        if(!q.empty())ans++,q.pop();
    }
    printf("%d\n",ans);
    
    return 0;
    
}