This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//DavitMarg
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <bitset>
#include <stack>
#include <cassert>
#include <iterator>
#include <random>
#include <chrono>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(), v.end()
#define fastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 500005;
int n, m;
int c[N];
pair<int, int> a[N];
void solve()
{
cin >> n >> m;
for (int i = 1; i <= n; i++)
cin >> a[i].first >> a[i].second;
for (int i = 1; i <= m; i++)
cin >> c[i];
sort(a + 1, a + 1 + n, [](pair<int, int> a, pair<int, int> b) {
if (a.second == b.second)
return a.first < b.first;
return a.second < b.second;
});
sort(c + 1, c + 1 + m);
int ans = 0;
int p = n;
for (int i = m; i >= 1; i--)
{
while (p >= 1 && a[p].first > c[i])
p--;
if (p >= 1 && a[p].first <= c[i])
{
ans++;
p--;
}
}
cout << ans << endl;
}
int main()
{
fastIO
int T = 1;
//cin >> T;
while (T--)
{
solve();
}
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... |