#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define int long long
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> a(n);
    for (auto &[f, s] : a) cin >> s >> f;
    sort(all(a));
    vector<int> b(m);
    for (int &i : b) cin >> i;
    sort(all(b));
    int ans = 0;
    reverse(all(a));
    for (auto [f, s] : a)
    {
        if (b.empty()) break;
        if (s <= b.back())
        {
            ans++;
            b.pop_back();
        }
    }
    cout << ans;
    return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |