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 fast cin.tie(0)->sync_with_stdio(0);
#define int long long
#define inf ((int)1e18)
using namespace std;
int32_t main(){
fast
int n, m;
cin >> n >> m;
vector <pair<int,int> > arr(n);
for(int i = 0; i < n; i++) {
cin >> arr[i].first >> arr[i].second;
}
vector <int> frames(m);
for(int i = 0; i < m; i++) {
cin >> frames[i];
}
sort(arr.begin(), arr.end(), [&](pair<int,int>&a, pair<int,int>&b) {
if(a.second == b.second) return a.first < b.first;
return a.second < b.second;
});
int ans = 0;
sort(frames.begin(), frames.end());
for(int i = n-1; i >= 0; i--) {
if(frames.size() == 0) break;
int frame = frames.back();
if(frame >= arr[i].first) {
ans++;
frames.pop_back();
}
}
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |