Submission #679553

#TimeUsernameProblemLanguageResultExecution timeMemory
679553etheningExhibition (JOI19_ho_t2)C++17
100 / 100
47 ms5040 KiB
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

struct pic {
	int sz, val;
};

int main() {
	cin.tie(0)->sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	vector<pic> p;
	vector<int> f;
	for (int i = 0; i < n; i++) {
		int sz, val;
		cin >> sz >> val;
		p.push_back({.sz = sz, .val = val});
	}
	for (int i = 0; i < m; i++) {
		int c;
		cin >> c;
		f.push_back(c);
	}
	sort(p.begin(), p.end(), [](pic &u, pic &v) {
		if (u.val < v.val) return true;
		else if (u.val > v.val) return false;
		else return u.sz < v.sz;
	});
	sort(f.begin(), f.end());

	int ans = 0;
	int pnt = m - 1;
	for (int i = n - 1; i >= 0; i--) {
		if (pnt == -1) continue;
		if (p[i].sz <= f[pnt]) {
			++ans;
			--pnt;
		}
	}

	cout << ans << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...