防晒

#include<iostream>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;
using PII=pair<int,int>;
const int N=2e3+510;
int n,m;
PII cows[N];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); 
	cin>>n>>m;
	map<int,int> spfs;
	for(int i=0;i<n;++i){
		cin>>cows[i].first>>cows[i].second;
	}
	for(int i=0;i<m;++i){
		int spf,cover;
		cin>>spf>>cover;
		spfs[spf]+=cover;//due to have same spf data
	}
	sort(cows,cows+n);
	int res=0;
	spfs[0]=spfs[1001]=n;
	for(int i=n-1;i>=0;--i){
		auto spf=spfs.upper_bound(cows[i].second);
		--spf;
		if(spf->first>=cows[i].first){
			++res;
			if(0==--spf->second){
				spfs.erase(spf);
			}
		}	
	}
	cout<<res<<'\n';
	return 0;
}
posted @ 2022-03-23 15:52  ethon-wang  阅读(16)  评论(0编辑  收藏  举报