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>
using namespace std;
int main(){
int n, m;
cin >> n >> m;
vector<pair<int, int> > pictures(n);
//value = first, size = second
for(int i = 0; i < n; i++){
cin >> pictures[i].second >> pictures[i].first;
}
vector<int> frames(m);
for(int i = 0; i < m; i++){
cin >> frames[i];
}
sort(pictures.begin(), pictures.end());
sort(frames.begin(), frames.end());
int current_idx = -1;
int ans = 0;
for(int i = 0; i < n; i++){
int low = current_idx + 1;
int high = m - 1;
int ans2 = -1;
while(low <= high){
int mid = (low + high)/2;
if(pictures[i].second <= frames[mid]){
high = mid - 1;
ans2 = mid;
}
else{
low = mid + 1;
}
}
if(ans2 != -1){
current_idx = ans2;
ans++;
}
}
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... |