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;
int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, m; cin >> n >> m;
set<pair<int, int>, greater<pair<int, int>>> a;
set<pair<int, int>> b;
vector<bool> dead(n);
deque<int> c(m);
for(int i=0; i<n; i++) {
int in; cin >> in;
a.insert({in, i});
}
for(int i=0; i<n; i++) {
int in; cin >> in;
b.insert({in, i});
}
for(int &p : c) cin >> p;
sort(c.begin(), c.end()); int ans=0;
for(auto [p, i] : a) {
if(c.empty()) break;
if(p>c.back()) continue;
dead[i]=1;
ans++; c.pop_back();
}
for(auto [p, i] : b) {
if(c.empty()) break;
if(dead[i]) continue;
if(p<c.front()) continue;
ans++; c.pop_front();
}
cout << ans << '\n';
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... |