Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <set>
- #include <algorithm>
- using namespace std;
- int main()
- {
- int n, m;
- cin >> n >> m;
- multiset<int> ms;
- for(int i = 0; i < n; i++) {
- int x;
- cin >> x;
- ms.insert(x);
- }
- int niza[m];
- for(int i = 0; i < m; i++) {
- cin >> niza[i];
- }
- for(int i = 0; i < m; i++) {
- auto it = ms.lower_bound(niza[i] + 1);
- if(it == ms.begin()) {
- cout << -1 << endl;
- }
- else {
- it--;
- cout << *it << endl;
- ms.erase(it);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement