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;
template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl
using ll = long long;
const int inf = 2e9;
void print(vector<int> a, int n) {
for (int i=0; i<n; i++) {
cout<<a[i]<<" ";
}
cout<<endl;
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
int n, m;
cin>>n>>m;
vector<pair<int,int>> a(n); // (val, size)
for (int i=0; i<n; i++) {
cin>>a[i].second>>a[i].first;
}
sort(a.begin(), a.end());
vector<int> w(m);
for (int i=0; i<m; i++) {
cin>>w[i];
}
sort(w.begin(),w.end());
int ans = 0;
int ptr = n-1;
for (int i=m-1; i>=0 && ptr>=0; i--) {
while (ptr>=0 && a[ptr].second > w[i]) ptr--;
if (ptr>=0) {
--ptr;
ans++;
}
}
cout<<ans<<endl;
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... |