#include <bits/stdc++.h>
using namespace std;
const int MM = 1e5+5;
int main(){
cin.tie(0)->sync_with_stdio(0);
int n,m,ans = 0; cin >> n >> m;
vector<array<int,2>> a; vector<int> b;
for(int i = 0; i < n; i++){
int s,v; cin >> s >> v;
a.push_back({s,v});
}
sort(a.begin(),a.end());
for(int j = 0; j < m; j++){
int c; cin >> c;
b.emplace_back(c);
}
sort(b.begin(),b.end());
multiset<int> st;
for(int i = 0; i < n; i++){
if(a[i][0] <= b[m-1]){
st.insert(a[i][1]);
}
}
for(int j = m-1, i = n-1; j >= 0; j--){
while(i >= 0 && a[i][0] > b[j]){
if(st.find(a[i][1]) != st.end()) st.erase(st.find(a[i][1]));
i--;
}
if(st.empty()) break;
ans++;
//cout << j << " " << *(--st.end()) << "\n";
st.erase(--st.end());
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
312 KB |
Output is correct |
3 |
Incorrect |
0 ms |
308 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
312 KB |
Output is correct |
3 |
Incorrect |
0 ms |
308 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
312 KB |
Output is correct |
3 |
Incorrect |
0 ms |
308 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |