題目大意:
解題思路:
先排個序然後用堆維護答案就可以了
#include<queue>
#include<cstdio>
#include<algorithm>
using namespace std;
const int N = 3e5;
struct num {
int l, r;
bool operator <(num x) const{ return r > x.r; }
} a[N];
int n, m, ans;
int t[N];
priority_queue<num> q;
bool cmp(num t1, num t2) {
return t1.l < t2.l || (t1.l == t2.l && t1.r < t2.r);
}
int main() {
scanf("%d %d", &n, &m);
for (int i = 1; i <= n; ++i) scanf("%d %d", &a[i].l, &a[i].r);
for (int i = 1; i <= m; ++i) scanf("%d", &t[i]);
sort(a + 1, a + 1 + n, cmp), sort(t + 1, t + 1 + m);
for (int i = 1, j = 1; i <= m; ++i) {
while (j <= n && a[j].l <= t[i]) q.push(a[j]), ++j;
while (q.size() && q.top().r < t[i]) q.pop();
if (q.size()) ans++, q.pop();
}
return !printf("%d", ans);
}