/*
水贪心,不解释
*/
#include <cstdio>
#include <iostream>
#include <memory.h>
#include<queue>
#include<set>
#include<algorithm>
using namespace std;
int n,m;
struct point
{
int Min,Max;
}p[40009];
bool cmp(point a,point b)
{
if(a.Max!=b.Max)
return a.Max<b.Max;
return a.Min<b.Min;
}
int main()
{
multiset<int> Set;
multiset<int>::iterator it;
while(scanf("%d%d",&n,&m)!=EOF)
{
Set.clear();
for(int i=0;i<n;i++)
scanf("%d%d",&p[i].Min,&p[i].Max);
sort(p,p+n,cmp);
int tmp,ans=0;
for(int i=0;i<m;i++)
{
scanf("%d",&tmp);
Set.insert(tmp);
}
for(int i=0;i<n;i++)
{
it=Set.lower_bound(p[i].Min);
if(it!=Set.end()&&*it<=p[i].Max)
{
ans++;
Set.erase(it);
}
}
cout<<ans<<endl;
}
return 0;
}
ZOJ 3508 The War
最新推荐文章于 2014-08-01 20:24:27 发布