Submission #220400

#TimeUsernameProblemLanguageResultExecution timeMemory
220400hanagasumiExhibition (JOI19_ho_t2)C++17
100 / 100
71 ms6760 KiB
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <deque>
#include <map>
#include <set>
#include <complex>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <random>

#define ft first
#define sc second
#define pb push_back
#define len(v) (int)v.size()
#define int ll

using namespace std;
typedef long long ll;

signed main() {
	 #ifdef PC 
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> have;
	vector<int> fr;
	for (int i = 0; i < n; i++) {
		int v, sz;
		cin >> sz >> v;
		have.pb({v, sz});
	}
	for (int i = 0; i < m; i++) {
		int sz;
		cin >> sz;
		fr.pb(sz);
	}
	sort(have.begin(), have.end());
	reverse(have.begin(), have.end());
	sort(fr.begin(), fr.end());
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if(len(fr) == 0) 
			continue;
		if(have[i].sc <= fr.back()) {
			ans++;
			fr.pop_back();
		}
	}
	cout << ans;
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...