防晒霜求调,全RE
查看原帖
防晒霜求调,全RE
1270926
wawatime1楼主2024/11/22 18:33

总感觉思路有问题。

#include<bits/stdc++.h>
using namespace std;
int c, l, ans;
struct nainiu {
	int mi, mx;
} s[3000];
struct fsh {
	int spf, cnt;
} f[3000];
bool cmp (nainiu x, nainiu y) {
	return x.mi < y.mi;
}
bool cmp2 (fsh x, fsh y) {
	return x.spf < y.spf;
}
int main () {
	scanf ("%d%d", &c, &l);
	for (int i = 1; i <= c; i++)
		scanf ("%d%d", &s[i].mi, &s[i].mx);
	for (int i = 1; i <= l; i++)
		scanf ("%d%d", &f[i].spf, &f[i].cnt);
	sort (s + 1, s + c + 1, cmp);
	sort (f + 1, f + l + 1, cmp2);
	for (int i = 1; i <= l; i++) {
		priority_queue<int, vector <int>, greater<int> > pq;
		int j = 1;
		while (s[j].mi <= f[i].spf) {
			pq.push (s[j].mx);
			j++;
		}
		while (!pq.empty() && pq.top() <= f[i].spf && f[i].cnt > 0) {
			ans++;
			f[i].cnt--;
			pq.pop();
		}
	}
	printf ("%d", ans);
	return 0;
}
2024/11/22 18:33
加载中...