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;
bool cmp(pair<long long, long long> a, pair<long long, long long> b) {
if(a.second == b.second)
return a.first < b.first;
return a.second < b.second;
}
void Solve() {
long long n, m;
cin >> n >> m;
vector<pair<long long, long long> > pictures(n + 1);
vector<long long> frames(m + 1);
for(long long i = 1; i <= n; i++) {
cin >> pictures[i].first >> pictures[i].second;
}
for(long long i = 1; i <= m; i++) {
cin >> frames[i];
}
sort(pictures.begin() + 1, pictures.begin() + 1 + n, cmp);
sort(frames.begin() + 1, frames.begin() + 1 + m);
/*cout << "Sorting of pictures was as follows" << endl;
for(long long i = 1; i <= n; i++) {
cout << pictures[i].first << " " << pictures[i].second << endl;
}
cout << "Sorting of frames was as follows" << endl;
for(long long i = 1; i <= m; i++) {
cout << frames[i] << " ";
}
cout << endl;*/
long long curAns = 0, curPic = n;
for(long long i = m; i > 0; i--) {
if(curPic <= 0)
break;
while(curPic > 0 && pictures[curPic].first > frames[i]) {
curPic--;
}
if(curPic > 0) {
curPic--;
curAns++;
}
}
cout << curAns << endl;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
Solve();
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... |