이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |