#include <bits/stdc++.h>
#define rep(a,b,c) for(auto a = (b); a != (c); a++)
#define repD(a,b,c) for(auto a = (b); a != (c); a--)
#define repIn(a, b) for(auto& a : (b))
#define repIn2(a, b, c) for(auto& [a, b] : (c))
constexpr bool dbg = 1;
#define DEBUG if constexpr(dbg)
#define DC DEBUG std::cerr
#define eol std::endl
#define ll long long
#define pb push_back
using namespace std;
int main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
int n, m;
cin >> n >> m;
priority_queue<pair<int, int>> q;
rep(i, 0, n) {
int x, y;
cin >> x >> y;
q.push({y, x});
}
vector<int> frames(m);
rep(i, 0, m) cin >> frames[i];
ranges::sort(frames);
ll ans = 0;
repD(i, m - 1, -1) {
while(!q.empty() && q.top().second > frames[i]) q.pop();
if(q.empty()) break;
ans++;
q.pop();
}
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |