This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
int b[m];
array<int, 2> a[n];
multiset<int> s;
for (array<int, 2> &x : a) cin >> x[0] >> x[1], s.insert(x[1]);
for (int &i : b) cin >> i;
sort(b, b + m);
sort(a, a + n);
int j = n - 1, res = 0;
for (int i = m - 1; i >= 0; i--)
{
while (j >= 0 && b[i] < a[j][0])
{
if (s.find(a[j][1]) != s.end()) s.erase(s.find(a[j][1]));
j--;
}
if (!s.empty()) res++, s.erase(--s.end());
}
cout << res << '\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... |