#include <bits/stdc++.h>
using namespace std;
#define iloop(x, n) for (long long i = x; i < n; ++i)
#define jloop(x, n) for (long long j = x; j < n; ++j)
#define kloop(x, n) for (long long k = x; k < n; ++k)
#define dloop(x, n) for (long long d = x; d >= n; --d)
#define ll long long
#define pll pair<long long, long long>
#define pii pair<int, int>
#define vi vector<long long>
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
#define int long long
#define debug(x) cout << #x << ": " << x << endl
#define FASTIO \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
int32_t main(){
FASTIO
int n, m; cin >> n >> m;
vector<pll> v;
vi f;
iloop(0, n){
int s, val;
cin >> s >> val;
v.pb({val, s});
}
sort(v.begin(), v.end(), [](pll a, pll b){
if (a.fst < b.fst) return false;
else if (a.fst == b.fst) return a.snd > b.snd;
else return true;
});
//for (auto it : v) cout << it.fst << " " << it.snd << " | ";
//cout << endl;
iloop(0, m){
int s; cin >> s;
f.pb(s);
}
sort(f.begin(), f.end(), greater<int>());
int pos = 0;
int cnt = 0;
iloop(0, m){
while (pos < n and v[pos].snd > f[i]){
pos++;
}
if (pos == n) break;
cnt++;
pos++;
}
cout << cnt;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |