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>
#define int long long
#define IO ios::sync_with_stdio(0), cin.tie(0)
#define FOR(i, a, b) for (int i = a, I = b; i <= I; i++)
using namespace std;
using pii = pair<int, int>;
void dbg() {;}
template<class T, class ...U>
void dbg(T a, U ...b) { cout << a << " "; dbg(b...); }
void ent() { cout << "\n"; }
const int N = 100005;
pii a[N];
int c[N];
signed main() {
IO;
int n, m;
cin >> n >> m;
FOR(i, 0, n - 1) cin >> a[i].first >> a[i].second;
FOR(i, 0, m - 1) cin >> c[i];
sort(a, a + n, [&] (pii p, pii q) {
if (p.second != q.second)
return p.second > q.second;
return p.first > q.first;
});
sort(c, c + m, greater<int>());
vector<int> tmp;
FOR(i, 0, n - 1) {
int x = tmp.size();
if (x < m && a[i].first <= c[x])
tmp.push_back(a[i].second);
}
cout << tmp.size() << "\n";
// for (int i : tmp) dbg(i);
return 0;
}
/*
4 3
100 3
15 4
8 2
7 3
9 8 7
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |