跪求dalao救救本蒟蒻,啊啊啊!
查看原帖
跪求dalao救救本蒟蒻,啊啊啊!
348028
123456yzx楼主2020/9/30 13:18
#include<bits/stdc++.h>
using namespace std;
struct cow {
	int a,b;
} cc[2505];
struct BB {
	int bb,bbn;
} aa[2505];

bool cmp1(cow x,cow y) {
	return x.b>y.b;
}
bool cmp2(BB x,BB y) {
	return x.bb>y.bb;
}

int c,l,sum=0;
int main() {
//	freopen("./P2887_2.in.txt","r",stdin);
	scanf("%d%d",&c,&l);
	for(int i=1; i<=c; i++) {
		scanf("%d%d",&cc[i].a,&cc[i].b);
	}
	for(int i=1; i<=l; i++) {
		scanf("%d%d",&aa[i].bb,&aa[i].bbn);
	}
	sort(cc+1,cc+1+c,cmp1);
	sort(aa+1,aa+1+l,cmp2);
	for(int i=1; i<=c; i++) {
		for(int j=1; j<=l; j++) {
			if(aa[j].bb<=cc[i].b&&aa[j].bb>=cc[i].a&&aa[j].bbn>0) {
				sum++;
				aa[j].bbn--;
				break;
			}
		}
	}
	printf("%d",sum);
	return 0;
}

https://www.luogu.com.cn/record/39045367

2020/9/30 13:18
加载中...