#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
vector<pair<long long, long long>> pic(n);
for(int i=0; i<n; i++){
cin >> pic[i].first >> pic[i].second; // size, value
}
vector<long long> c(m);
for(int i=0; i<m; i++) cin >> c[i];
sort(pic.begin(), pic.end(), [](auto &a, auto &b){
if(a.second != b.second) return a.second < b.second;
return a.first < b.first;
});
multiset<long long> frames(c.begin(), c.end());
long long prev = 0;
int res = 0;
for(auto [s, v] : pic){
auto it = frames.lower_bound(max(s, prev));
if(it != frames.end()){
prev = *it;
frames.erase(it);
res++;
}
}
cout << res << '\n';
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |