This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///In the name of GOD
//#pragma GCC optimize("O2")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MXN = 1e5 + 10;
ll n, m, ans, pnt;
ll S[MXN], V[MXN], C[MXN];
vector<ll> Ind;
int main(){
ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
cin >> n >> m;
for(int i = 1; i <= n; i ++){
cin >> S[i] >> V[i];
Ind.push_back(i);
}
for(int i = 1; i <= m; i ++){
cin >> C[i];
}
sort(C + 1, C + m + 1, greater<ll>());
sort(Ind.begin(), Ind.end(), [&](const int& i, const int& j){
return (V[i] > V[j] || (V[i] == V[j] && S[i] > S[j]));
});
pnt = 1;
for(auto i : Ind){
if(S[i] <= C[pnt]){
ans ++;
pnt ++;
}
}
cout << ans << '\n';
return 0;
}
/*!
HE'S AN INSTIGATOR,
ENEMY ELIMINATOR,
AND WHEN HE KNOCKS YOU BETTER
YOU BETTER LET HIM IN.
*/
//! N.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... |