#include <bits/stdc++.h>
#define int long long
using namespace std;
ostream &operator <<(ostream &out, vector <int> val) {
for (auto v : val) {
out << v << ' ';
}
return out;
}
void solve() {
int n, m;
cin >> n >> m;
vector <pair <int, int>> val(n);
for (int i = 0; i < n; ++i) {
cin >> val[i].first >> val[i].second;
}
vector <int> c(m);
for (auto &v : c) {
cin >> v;
}
sort(c.begin(), c.end());
sort(val.begin(), val.end(), [](pair <int, int> &v1, pair <int, int> &v2) {
return v1.second < v2.second || (v1.second == v2.second && v1.first < v2.first);
});
int ind1 = n - 1, ind2 = m - 1;
int ans = 0;
while (ind1 > - 1 && ind2 > - 1) {
if (val[ind1].first <= c[ind2]) {
--ind1;
--ind2;
++ans;
} else {
--ind1;
}
}
cout << ans << '\n';
}
signed main() {
cin.tie(0);
ios::sync_with_stdio(false);
int t = 1;
solve();
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |