#include <algorithm>
#include <iostream>
using namespace std;
#define ii pair <int, int>
#define fi first
#define se second
const int N = 1e5 + 10;
int n, m, b[N];
ii a[N];
bool cmp (const ii &x, const ii &y) {
if (x.se == y.se) return x.fi > y.fi;
return x.se > y.se;
}
int main() {
cin.tie(0); cout.tie(0);
ios_base::sync_with_stdio(false);
cin >> n >> m;
for (int i = 1; i <= n; ++i) {
cin >> a[i].fi >> a[i].se;
}
sort(a + 1, a + n + 1, cmp);
for (int i = 1; i <= m; ++i) cin >> b[i];
sort(b + 1, b + m + 1);
int j = 1, ans = 0;
for (int i = m; i >= 1; --i) {
while (j <= n && a[j].fi > b[i]) ++j;
if (j <= n) {
++ans;
++j;
} else break;
}
cout << ans << "\n";
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... |