#include <bits/stdc++.h>
#define int long long
using namespace std;
const long long N = 2e5 + 5;
int a[N];
struct photo
{
int value, size;
};
void solve()
{
int n, m;
cin >> n >> m;
vector<photo> a(n);
vector<int> frame;
int e;
for (int i = 0; i < n; i++)
{
cin >> a[i].size >> a[i].value;
}
for (int i = 0; i < m; i++)
{
cin >> e;
frame.push_back(e);
}
sort(frame.rbegin(), frame.rend());
sort(a.begin(), a.end(), [&](photo a, photo b)
{
if (a.value == b.value) return a.size < b.size;
return a.value < b.value; });
int j = 0;
int ans = 0;
for (int i = 0; i < n; i++)
{
if (j < m and a[i].size <= frame[j])
{
j++;
ans++;
}
}
cout << ans << endl;
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(NULL);
cout.tie(NULL);
int t = 1;
// cin >> t;
for (int i = 1; i <= t; i++)
{
// cout << "Case #" << i << ':' << ' ';
solve();
cout << endl;
}
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... |