Submission #1114167

#TimeUsernameProblemLanguageResultExecution timeMemory
1114167davitmargExhibition (JOI19_ho_t2)C++17
100 / 100
43 ms7756 KiB
//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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...