记录编号 |
589308 |
评测结果 |
AAAAAAAAAA |
题目名称 |
梦境 |
最终得分 |
100 |
用户昵称 |
djyqjy |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.412 s |
提交时间 |
2024-07-04 17:40:30 |
内存使用 |
3.09 MiB |
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
const int N=200010;
int n,m;
struct as
{
long long l,r;
}a[N];
priority_queue <as> q;
long long b[N];
int l=1;
long long ans;
bool cmp(as x,as y){return x.l<y.l;}
bool operator <(as x,as y){return x.r>y.r;}
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("%lld%lld",&a[i].l,&a[i].r);
for(int i=1;i<=m;i++)
scanf("%lld",&b[i]);
sort(a+1,a+1+n,cmp);
sort(b+1,b+1+m);
for(int i=1;i<=m;i++)
{
while(l<=n&&a[l].l<=b[i]) q.push(a[l++]);
while(q.size()&&q.top().r<b[i]) q.pop();
if(q.size())
{
q.pop();
ans++;
}
}
printf("%lld",ans);
return 0;
}