比赛 2024暑期C班集训4 评测结果 WWWWWWWWWW
题目名称 梦境 最终得分 0
用户昵称 健康铀 运行时间 1.789 s
代码语言 C++ 内存使用 4.12 MiB
提交时间 2024-07-04 10:30:05
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
long long top=1,n,m,a[200010],ans;
struct abc{
    long long x;
    long long y;
    bool operator<(abc z)const{
        return y>z.y;
    }
};
abc b[200010];
priority_queue<abc>q ;
bool cmp(abc A,abc B){
   return A.x<B.x;
}
int main(){
    freopen("dream.in","r",stdin);
    freopen("dream.out","w",stdout);
    cin>>n>>m;
    for(long long i=1;i<=n;i++)
    cin>>b[i].x>>b[i].y;
    for(long long i=1;i<=m;i++)
    cin>>a[i];
    sort(b+1,b+n+1,cmp);
    sort(a+1,a+m+1);
    for(long long i=1;i<=m;i++)
    cout<<a[i]<<endl;
    for(long long i=1;i<=m;i++){
        while(top<=n&&a[i]-b[top].x>=0){
            q.push(b[top]);
            top++;
        }
        while(!q.empty()&&q.top().y<a[i])
        q.pop();
        if(!q.empty()){
            ans++;
            q.pop();
        }
    }
    cout<<ans;
    return 0;
}