比赛 NOIP2023模拟赛2 评测结果 WWWWWWWWWW
题目名称 梦境 最终得分 0
用户昵称 ┭┮﹏┭┮ 运行时间 0.325 s
代码语言 C++ 内存使用 2.41 MiB
提交时间 2023-11-14 10:13:52
显示代码纯文本
#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(r == x.r)return l < x.l;
        else return r < x.r;
    }
}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;
    for(int i = 1;i <= n;i++){
        while(b[j] < a[i].l)j++;
        if(a[i].l <= b[j] && b[j] <= a[i].r)ans++,j++;
        if(j > m)break;
    }
    printf("%d\n",ans);
    
    return 0;
    
}