Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <set>
- using namespace std;
- int main()
- {
- int n, m;
- cin >> n >> m;
- int h[n], t[m];
- multiset<int> ms;
- for(int i = 0; i < n; i++) {
- cin >> h[i];
- ms.insert(h[i]);
- }
- for(int i = 0; i < m; i++) {
- cin >> t[i];
- }
- for(int i = 0; i < m; i++) {
- auto it = ms.upper_bound(t[i]);
- 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