题意:
有n头奶牛
解析:
#include<bits/stdc++.h>
#define x first
#define y second
using namespace std;
const int N=1e5+1000;
priority_queue<int,vector<int>,greater<int> >q;
struct node
{
int l,r;
bool operator < (const node &W){
return l<W.l;
}
}a[N],b[N];
int c,l,u,v;
int main()
{
cin>>c>>l;
for(int i=1;i<=c;i++)
{
cin>>a[i].l>>a[i].r;
}
for(int i=1;i<=l;i++)
{
cin>>b[i].l>>b[i].r;
}
sort(a+1,a+1+c);
sort(b+1,b+1+l);
int p=1;
int sum=0;
int j=1;
for(int i=1;i<=l;i++)
{
while(j<=c&&a[j].l<=b[i].l) q.push(a[j].r),j++;
while(q.size()&&b[i].r)
{
int t=q.top();q.pop();
if(t<b[i].l) continue;
sum++;
b[i].r--;
}
}
cout<<sum<<endl;
}