求助
查看原帖
求助
119618
MKqwq_楼主2020/10/4 15:00

38分,卡在点2

#include<bits/stdc++.h>
using namespace std;
struct cw{
	int mx,mn;
}a[2501],b[2501];
int c,l,ans=0;
bool cmp(const cw&x,const cw&y){
	if(x.mn<y.mn||x.mn==y.mn&&x.mx<y.mx) return 1;
	return 0;
}
bool cmp1(const cw&x,const cw&y){
	if(x.mn<y.mn) return 1;
	return 0;
}
int main(){
	cin>>c>>l;
	for(int i=1;i<=c;i++) cin>>a[i].mn>>a[i].mx;
	for(int i=1;i<=l;i++) cin>>b[i].mn>>b[i].mx;
	sort(a+1,a+c+1,cmp);
	sort(b+1,b+l+1,cmp);
//	cout<<endl;
//	for(int i=1;i<=c;i++) cout<<a[i].mn<<" "<<a[i].mx<<endl;
//	cout<<endl;
//	for(int i=1;i<=l;i++) cout<<b[i].mn<<" "<<b[i].mx<<endl;
//	cout<<endl;
	for(int i=1;i<=c;i++)
		for(int j=1;j<=l;j++)
			if(b[j].mn>=a[i].mn&&b[j].mn<=a[i].mx&&b[j].mx>=1){
				ans++,b[j].mx--;
				break;
			} 
		//	else cout<<i<<" "<<j<<endl;
	cout<<ans;
	return 0;
}

/tk

2020/10/4 15:00
加载中...